public void Should_format_xml_without_description_nor_label_nor_details() { var result = new FeatureResult("Feature name", null, null); result.AddScenario(new ScenarioResult("name", new[] { new StepResult(1, "step1", ResultStatus.Passed), new StepResult(2, "step2", ResultStatus.Ignored) }, null)); result.AddScenario(new ScenarioResult("name2", new[] { new StepResult(1, "step3", ResultStatus.Passed), new StepResult(2, "step4", ResultStatus.Failed) }, null)); var text = _subject.Format(result); Console.WriteLine(text); const string expectedText = @"<?xml version=""1.0"" encoding=""utf-8""?> <TestResults> <Feature Name=""Feature name""> <Scenario Status=""Ignored"" Name=""name""> <Step Status=""Passed"" Number=""1"" Name=""step1"" /> <Step Status=""Ignored"" Number=""2"" Name=""step2"" /> </Scenario> <Scenario Status=""Failed"" Name=""name2""> <Step Status=""Passed"" Number=""1"" Name=""step3"" /> <Step Status=""Failed"" Number=""2"" Name=""step4"" /> </Scenario> </Feature> </TestResults>"; Assert.That(text, Is.EqualTo(expectedText)); }
public void Should_format_xml() { var result = new FeatureResult("Feature name", "feature\nlong description", "Label 1"); result.AddScenario(new ScenarioResult("name", new[] { new StepResult(1, "step1", ResultStatus.Passed), new StepResult(2, "step2", ResultStatus.Ignored, "Not implemented yet") }, "Label 2")); result.AddScenario(new ScenarioResult("name2", new[] { new StepResult(1, "step3", ResultStatus.Passed), new StepResult(2, "step4", ResultStatus.Failed, " Expected: True\n But was: False") }, null)); var text = _subject.Format(result); Console.WriteLine(text); const string expectedText = @"<?xml version=""1.0"" encoding=""utf-8""?> <TestResults> <Feature Name=""Feature name"" Label=""Label 1""> <Description>feature long description</Description> <Scenario Status=""Ignored"" Name=""name"" Label=""Label 2""> <Step Status=""Passed"" Number=""1"" Name=""step1"" /> <Step Status=""Ignored"" Number=""2"" Name=""step2"" /> <StatusDetails>Not implemented yet</StatusDetails> </Scenario> <Scenario Status=""Failed"" Name=""name2""> <Step Status=""Passed"" Number=""1"" Name=""step3"" /> <Step Status=""Failed"" Number=""2"" Name=""step4"" /> <StatusDetails> Expected: True But was: False</StatusDetails> </Scenario> </Feature> </TestResults>"; Assert.That(text, Is.EqualTo(expectedText)); }
public void Should_format_feature_with_description() { var result = new FeatureResult("My feature", string.Format("My feature{0}long description", Environment.NewLine), "Label 1"); result.AddScenario(new ScenarioResult("name", new[] { new StepResult(1, "step1", ResultStatus.Passed), new StepResult(2, "step2", ResultStatus.Ignored, "Not implemented yet") }, "Label 2")); result.AddScenario(new ScenarioResult("name2", new[] { new StepResult(1, "step3", ResultStatus.Passed), new StepResult(2, "step4", ResultStatus.Failed, string.Format(" Expected: True{0} But was: False", Environment.NewLine)) }, null)); var text = _subject.Format(result); const string expectedText = @"Feature: [Label 1] My feature My feature long description Scenario: [Label 2] name - Ignored Step 1: step1 - Passed Step 2: step2 - Ignored Details: Not implemented yet Scenario: name2 - Failed Step 1: step3 - Passed Step 2: step4 - Failed Details: Expected: True But was: False "; Assert.That(text, Is.EqualTo(expectedText)); }
public void Should_format_feature_without_description_nor_label_nor_details() { var result = new FeatureResult("My feature", null, null); result.AddScenario(new ScenarioResult("name", new[] { new StepResult(1, "step1", ResultStatus.Passed), new StepResult(2, "step2", ResultStatus.Ignored) }, null)); var text = _subject.Format(result); const string expectedText = @"Feature: My feature Scenario: name - Ignored Step 1: step1 - Passed Step 2: step2 - Ignored "; Assert.That(text, Is.EqualTo(expectedText)); }
public void Should_add_result_be_thread_safe() { var results = new List <ScenarioResult>(); for (int i = 0; i < 1000; ++i) { results.Add(new ScenarioResult(i.ToString(CultureInfo.InvariantCulture), Enumerable.Empty <IStepResult>(), null)); } results.AsParallel().ForAll(r => _subject.AddScenario(r)); foreach (var result in results) { Assert.That(_subject.Scenarios.Contains(result), string.Format("Result {0} is missing", result.Name)); } }
private void RunScenario(string scenarioName, string label, IEnumerable <Step> steps) { ProgressNotifier.NotifyScenarioStart(scenarioName, label); var stepsToExecute = steps.ToArray(); try { foreach (var step in stepsToExecute) { PerformStep(step, stepsToExecute.Length); } } finally { var result = new ScenarioResult(scenarioName, stepsToExecute.Select(s => s.Result), label); _result.AddScenario(result); ProgressNotifier.NotifyScenarioFinished(result.Status, result.StatusDetails); } }