void ITestTracer.TraceNoMatchingStepDefinition(StepInstance stepInstance, ProgrammingLanguage targetLanguage, CultureInfo bindingCulture, List <BindingMatch> matchesWithoutScopeCheck) { TraceNoMatchingStepDefinition(stepInstance, targetLanguage, bindingCulture, matchesWithoutScopeCheck); allure.StopStep(x => x.status = Status.broken); allure.UpdateTestCase(x => { x.status = Status.broken; x.statusDetails = new StatusDetails { message = noMatchingStepMessage }; }); }
public void AfterScenario() { _scenario.TryGetValue(out TestResult testresult); allure.UpdateTestCase(testresult.uuid, x => x.name = x.name + ": " + _scenario.ScenarioInfo.Description); // allure.UpdateTestCase(testresult.uuid, x => x.labels.Add("Date", "050505"); }
private void AllureHackForScenarioOutlineTests() { ScenarioContext.TryGetValue(out TestResult result); AllureLifecycle.UpdateTestCase(result.uuid, test => { test.name = ScenarioContext.ScenarioInfo.Title; test.historyId = Guid.NewGuid().ToString(); }); }
private static void AllureHackForScenarioOutlineTests() { _scenarioContext.TryGetValue(out TestResult testresult); _allureLifecycle.UpdateTestCase(testresult.uuid, tc => { tc.name = _scenarioContext.ScenarioInfo.Title; tc.historyId = Guid.NewGuid().ToString(); }); }
public void FirstAfterScenario() { var scenarioId = PluginHelper.GetCurrentTestCase(scenarioContext).uuid; // update status to passed if there were no step of binding failures allure .UpdateTestCase(scenarioId, x => x.status = (x.status != Status.none) ? x.status : Status.passed) .StopTestCase(scenarioId); }
public static bool stopTest(string testId, Status status, string message, string trace) { StatusDetails std = new StatusDetails { flaky = false, known = true, message = message, trace = trace, muted = false }; instance = instance.UpdateTestCase(testId, x => x.status = status); instance = instance.UpdateTestCase(testId, x => x.statusDetails = std); instance.StopTestCase(testId) .WriteTestCase(testId); return(true); }
public virtual void AfterTest(ITest test) { var currentAction = (ITestAction)this; var testActions = GetCurrentActions(test); if (testActions.Last() == currentAction) { Allure.UpdateTestCase(x => x.statusDetails = new StatusDetails { message = TestContext.CurrentContext.Result.Message, trace = TestContext.CurrentContext.Result.StackTrace }); Allure.StopTestCase(x => x.status = GetNunitStatus(TestContext.CurrentContext.Result.Outcome.Status)); Allure.WriteTestCase(test.Id); } }
public override object InvokeBinding(IBinding binding, IContextManager contextManager, object[] arguments, ITestTracer testTracer, out TimeSpan duration) { var hook = binding as HookBinding; // process hook if (hook != null) { var featureContainerId = AllureHelper.GetFeatureContainerId(contextManager.FeatureContext?.FeatureInfo); switch (hook.HookType) { case HookType.BeforeFeature: if (hook.HookOrder == int.MinValue) { // starting point var featureContainer = new TestResultContainer { uuid = AllureHelper.GetFeatureContainerId(contextManager.FeatureContext?.FeatureInfo) }; allure.StartTestContainer(featureContainer); contextManager.FeatureContext.Set(new HashSet <TestResultContainer>()); contextManager.FeatureContext.Set(new HashSet <TestResult>()); return(base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration)); } else { try { this.StartFixture(hook, featureContainerId); var result = base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration); allure.StopFixture(x => x.status = Status.passed); return(result); } catch (Exception ex) { allure.StopFixture(x => x.status = Status.broken); // if BeforeFeature is failed execution is stopped. We need to create, update, stop and write everything here. // create fake scenario container var scenarioContainer = AllureHelper.StartTestContainer(contextManager.FeatureContext, null); // start fake scenario var scenario = AllureHelper.StartTestCase(scenarioContainer.uuid, contextManager.FeatureContext, null); // update, stop and write allure .StopTestCase(x => { x.status = Status.broken; x.statusDetails = AllureHelper.GetStatusDetails(ex); }) .WriteTestCase(scenario.uuid) .StopTestContainer(scenarioContainer.uuid) .WriteTestContainer(scenarioContainer.uuid) .StopTestContainer(featureContainerId) .WriteTestContainer(featureContainerId); throw; } } case HookType.BeforeStep: case HookType.AfterStep: { var scenario = AllureHelper.GetCurrentTestCase(contextManager.ScenarioContext); try { return(base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration)); } catch (Exception ex) { allure .UpdateTestCase(scenario.uuid, x => { x.status = Status.broken; x.statusDetails = AllureHelper.GetStatusDetails(ex); }); throw; } } case HookType.BeforeScenario: case HookType.AfterScenario: if (hook.HookOrder == int.MinValue || hook.HookOrder == int.MaxValue) { return(base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration)); } else { var scenarioContainer = AllureHelper.GetCurrentTestConainer(contextManager.ScenarioContext); try { this.StartFixture(hook, scenarioContainer.uuid); var result = base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration); allure.StopFixture(x => x.status = Status.passed); return(result); } catch (Exception ex) { allure.StopFixture(x => x.status = Status.broken); // get or add new scenario var scenario = AllureHelper.GetCurrentTestCase(contextManager.ScenarioContext) ?? AllureHelper.StartTestCase(scenarioContainer.uuid, contextManager.FeatureContext, contextManager.ScenarioContext); allure.UpdateTestCase(scenario.uuid, x => { x.status = Status.broken; x.statusDetails = AllureHelper.GetStatusDetails(ex); }); throw; } } case HookType.AfterFeature: if (hook.HookOrder == int.MaxValue) // finish point { WriteScenarios(contextManager); allure .StopTestContainer(featureContainerId) .WriteTestContainer(featureContainerId); return(base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration)); } else { try { StartFixture(hook, featureContainerId); var result = base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration); allure.StopFixture(x => x.status = Status.passed); return(result); } catch (Exception ex) { var scenario = contextManager.FeatureContext.Get <HashSet <TestResult> >().Last(); allure .StopFixture(x => x.status = Status.broken) .UpdateTestCase(scenario.uuid, x => { x.status = Status.broken; x.statusDetails = AllureHelper.GetStatusDetails(ex); }); WriteScenarios(contextManager); allure .StopTestContainer(featureContainerId) .WriteTestContainer(featureContainerId); throw; } } case HookType.BeforeScenarioBlock: case HookType.AfterScenarioBlock: case HookType.BeforeTestRun: case HookType.AfterTestRun: default: return(base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration)); } } else { return(base.InvokeBinding(binding, contextManager, arguments, testTracer, out duration)); } }
void ITestTracer.TraceNoMatchingStepDefinition(StepInstance stepInstance, ProgrammingLanguage targetLanguage, CultureInfo bindingCulture, List <BindingMatch> matchesWithoutScopeCheck) { base.TraceNoMatchingStepDefinition(stepInstance, targetLanguage, bindingCulture, matchesWithoutScopeCheck); allure.StopStep(x => x.status = Status.skipped); allure.UpdateTestCase(x => x.status = Status.skipped); }