Ejemplo n.º 1
0
        private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults)
        {
            foreach (var featureElement in featureTreeNode.Feature.FeatureElements)
            {
                var scenario = featureElement as Scenario;

                if (scenario != null)
                {
                    featureElement.Result = testResults.GetScenarioResult(scenario);
                    continue;
                }

                var scenarioOutline = featureElement as ScenarioOutline;

                if (scenarioOutline != null)
                {
                    foreach (var example in scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows))
                    {
                        example.Result = testResults.GetExampleResult(scenarioOutline, example.Cells.ToArray());
                    }

                    scenarioOutline.Result =
                        scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows)
                        .Select(row => row.Result)
                        .Merge();
                }
            }
        }
Ejemplo n.º 2
0
        public void Format(XElement parentElement, Scenario scenario)
        {
            var section = new XElement("section",
                                       new XElement("title", scenario.Name));

            if (configuration.HasTestResults)
            {
                TestResult testResult = nunitResults.GetScenarioResult(scenario);
                if (testResult.WasExecuted && testResult.WasSuccessful)
                {
                    section.Add(new XElement("note", "This scenario passed"));
                }
                else if (testResult.WasExecuted && !testResult.WasSuccessful)
                {
                    section.Add(new XElement("note", "This scenario failed"));
                }
            }

            if (!string.IsNullOrEmpty(scenario.Description))
            {
                section.Add(new XElement("p", scenario.Description));
            }

            foreach (Step step in scenario.Steps)
            {
                ditaStepFormatter.Format(section, step);
            }

            parentElement.Add(section);
        }
Ejemplo n.º 3
0
        public void Format(Body body, Scenario scenario)
        {
            if (configuration.HasTestResults)
            {
                TestResult testResult = nunitResults.GetScenarioResult(scenario);
                if (testResult.WasExecuted && testResult.WasSuccessful)
                {
                    body.GenerateParagraph("Passed", "Passed");
                }
                else if (testResult.WasExecuted && !testResult.WasSuccessful)
                {
                    body.GenerateParagraph("Failed", "Failed");
                }
            }

            body.GenerateParagraph(scenario.Name, "Heading2");
            if (!string.IsNullOrEmpty(scenario.Description))
            {
                body.GenerateParagraph(scenario.Description, "Normal");
            }

            foreach (Step step in scenario.Steps)
            {
                wordStepFormatter.Format(body, step);
            }
        }
Ejemplo n.º 4
0
 private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults)
 {
     foreach (var scenario in featureTreeNode.Feature.FeatureElements)
     {
         scenario.Result = scenario.GetType().Name == "Scenario"
                               ? testResults.GetScenarioResult(scenario as Scenario)
                               : testResults.GetScenarioOutlineResult(scenario as ScenarioOutline);
     }
 }
Ejemplo n.º 5
0
 private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults)
 {
     foreach (var scenario in featureTreeNode.Feature.FeatureElements)
     {
         scenario.Result = scenario.GetType().Name == "Scenario"
                               ? testResults.GetScenarioResult(scenario as Scenario)
                               : testResults.GetScenarioOutlineResult(scenario as ScenarioOutline);
     }
 }
Ejemplo n.º 6
0
        public XElement Format(Scenario scenario)
        {
            if (configuration.HasTestResults)
            {
                TestResult scenarioResult = results.GetScenarioResult(scenario);

                return(scenarioResult.WasExecuted ? BuildImageElement(scenarioResult) : null);
            }

            return(null);
        }
Ejemplo n.º 7
0
        public void GetScenarioResult_TwoInconclusive_ReturnsInconclusive()
        {
            var scenario = new Scenario();

            var testResults1 = SetupStubForGetScenarioResult(TestResult.Inconclusive);
            var testResults2 = SetupStubForGetScenarioResult(TestResult.Inconclusive);

            ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object);

            var result = multipleTestResults.GetScenarioResult(scenario);

            Check.That(result).IsEqualTo(TestResult.Inconclusive);
        }
Ejemplo n.º 8
0
        public void GetScenarioResult_OnePassingOneFailing_ReturnsFailed()
        {
            var scenario = new Scenario();

            var testResults1 = SetupStubForGetScenarioResult(TestResult.Passed);
            var testResults2 = SetupStubForGetScenarioResult(TestResult.Failed);

            ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object);

            var result = multipleTestResults.GetScenarioResult(scenario);

            Check.That(result).IsEqualTo(TestResult.Failed);
        }
        public void GetScenarioResult_OnePassingOneInconclusive_ReturnsPassed()
        {
            var scenario = new Scenario();

            var testResults1 = SetupStubForGetScenarioResult(TestResult.Passed);
            var testResults2 = SetupStubForGetScenarioResult(TestResult.Inconclusive);

            ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object);

            var result = multipleTestResults.GetScenarioResult(scenario);

            result.ShouldEqual(TestResult.Passed);
        }
        public void GetScenarioResult_OnePassingOneInconclusive_ReturnsPassed()
        {
            var scenario = new Scenario();

            var testResults1 = SetupStubForGetScenarioResult(TestResult.Passed);
            var testResults2 = SetupStubForGetScenarioResult(TestResult.Inconclusive);

            ITestResults multipleTestResults = CreateMultipleTestResults(testResults1, testResults2);

            var result = multipleTestResults.GetScenarioResult(scenario);

            Check.That(result).IsEqualTo(TestResult.Passed);
        }
Ejemplo n.º 11
0
        public void Format(IXLWorksheet worksheet, Scenario scenario, ref int row)
        {
            int originalRow = row;

            worksheet.Cell(row, "B").Style.Font.SetBold();
            worksheet.Cell(row++, "B").Value = scenario.Name;
            worksheet.Cell(row++, "C").Value = scenario.Description;

            var results = testResults.GetScenarioResult(scenario);

            if (configuration.HasTestResults && results.WasExecuted)
            {
                worksheet.Cell(originalRow, "B").Style.Fill.SetBackgroundColor(results.WasSuccessful
                                                                                   ? XLColor.AppleGreen
                                                                                   : XLColor.CandyAppleRed);
            }


            foreach (Step step in scenario.Steps)
            {
                excelStepFormatter.Format(worksheet, step, ref row);
            }
        }
Ejemplo n.º 12
0
        private static void SetResultsForIndividualScenariosUnderFeature(FeatureNode featureTreeNode, ITestResults testResults)
        {
            foreach (var featureElement in featureTreeNode.Feature.FeatureElements)
            {
              var scenario = featureElement as Scenario;

              if (scenario != null)
              {
                featureElement.Result = testResults.GetScenarioResult(scenario);
                continue;
              }

              var scenarioOutline = featureElement as ScenarioOutline;

              if (scenarioOutline != null)
              {
                if (testResults.SupportsExampleResults)
                {
                  foreach (var example in scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows))
                  {
                    example.Result = testResults.GetExampleResult(scenarioOutline, example.ToArray());
                  }

                  scenarioOutline.Result =
                    scenarioOutline.Examples.SelectMany(e => e.TableArgument.DataRows).Select(row => row.Result).Merge();
                }
                else
                {
                  featureElement.Result = testResults.GetScenarioOutlineResult(scenarioOutline);
                }
                continue;
              }
            }
        }