public void Format(IXLWorksheet worksheet, Feature feature) { worksheet.Cell("A1").Style.Font.SetBold(); worksheet.Cell("A1").Value = feature.Name; worksheet.Cell("B2").Value = feature.Description; worksheet.Cell("B2").Style.Alignment.WrapText = false; var results = testResults.GetFeatureResult(feature); if (configuration.HasTestResults && results.WasExecuted) { worksheet.Cell("A1").Style.Fill.SetBackgroundColor(results.WasSuccessful ? XLColor.AppleGreen : XLColor.CandyAppleRed); } int row = 4; foreach (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { excelScenarioFormatter.Format(worksheet, scenario, ref row); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { excelScenarioOutlineFormatter.Format(worksheet, scenarioOutline, ref row); } row++; } }
public void Format(FeatureDirectoryTreeNode featureNode) { Feature feature = featureNode.Feature; var topic = new XElement("topic", new XAttribute("id", feature.Name.ToDitaName())); topic.Add(new XElement("title", feature.Name)); topic.Add(new XElement("shortdesc", feature.Description)); var body = new XElement("body"); topic.Add(body); if (configuration.HasTestResults) { TestResult testResult = nunitResults.GetFeatureResult(feature); if (testResult.WasExecuted && testResult.WasSuccessful) { body.Add(new XElement("note", "This feature passed")); } else if (testResult.WasExecuted && !testResult.WasSuccessful) { body.Add(new XElement("note", "This feature failed")); } } foreach (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { ditaScenarioFormatter.Format(body, scenario); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { ditaScenarioOutlineFormatter.Format(body, scenarioOutline); } } // HACK - This relative path stuff needs to be refactored string relativePath = new FileInfo(Path.Combine(configuration.OutputFolder.FullName, featureNode.RelativePathFromRoot)). Directory.FullName.ToLowerInvariant(); if (!Directory.Exists(relativePath)) { Directory.CreateDirectory(relativePath); } string filename = Path.Combine(relativePath, feature.Name.ToDitaName() + ".dita"); var document = new XDocument(new XDocumentType("topic", "-//OASIS//DTD DITA Topic//EN", "topic.dtd", string.Empty), topic); document.Save(filename); }
public XElement Format(Feature feature) { if (configuration.HasTestResults) { TestResult scenarioResult = results.GetFeatureResult(feature); return(scenarioResult.WasExecuted ? BuildImageElement(scenarioResult) : null); } return(null); }
public void GetFeatureResult_OnePassingOneFailed_ReturnsPassed() { var feature = new Feature(); var testResults1 = SetupStubForGetFeatureResult(feature, TestResult.Passed); var testResults2 = SetupStubForGetFeatureResult(feature, TestResult.Failed); ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object); var result = multipleTestResults.GetFeatureResult(feature); Check.That(result).IsEqualTo(TestResult.Failed); }
public void GetFeatureResult_TwoInconclusive_ReturnsInconclusive() { var feature = new Feature(); var testResults1 = SetupStubForGetFeatureResult(feature, TestResult.Inconclusive); var testResults2 = SetupStubForGetFeatureResult(feature, TestResult.Inconclusive); ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object); var result = multipleTestResults.GetFeatureResult(feature); Check.That(result).IsEqualTo(TestResult.Inconclusive); }
public void GetFeatureResult_OnePassingOneInconclusive_ReturnsPassed() { var feature = new Feature(); var testResults1 = SetupStubForGetFeatureResult(feature, TestResult.Passed); var testResults2 = SetupStubForGetFeatureResult(feature, TestResult.Inconclusive); ITestResults multipleTestResults = CreateMultipleTestResults(testResults1.Object, testResults2.Object); var result = multipleTestResults.GetFeatureResult(feature); result.ShouldEqual(TestResult.Passed); }
public void GetFeatureResult_OnePassingOneInconclusive_ReturnsPassed() { var feature = new Feature(); var testResults1 = SetupStubForGetFeatureResult(feature, TestResult.Passed); var testResults2 = SetupStubForGetFeatureResult(feature, TestResult.Inconclusive); ITestResults multipleTestResults = CreateMultipleTestResults(testResults1, testResults2); var result = multipleTestResults.GetFeatureResult(feature); Check.That(result).IsEqualTo(TestResult.Passed); }
public void Build(GeneralTree <IDirectoryTreeNode> features) { if (log.IsInfoEnabled) { log.InfoFormat("Writing JSON to {0}", configuration.OutputFolder.FullName); } var featuresToFormat = new List <FeatureWithMetaInfo>(); var actionVisitor = new ActionVisitor <IDirectoryTreeNode>(node => { var featureTreeNode = node as FeatureDirectoryTreeNode; if (featureTreeNode != null) { if (configuration.HasTestResults) { featuresToFormat.Add( new FeatureWithMetaInfo( featureTreeNode, testResults. GetFeatureResult( featureTreeNode. Feature))); } else { featuresToFormat.Add( new FeatureWithMetaInfo( featureTreeNode)); } } }); features.AcceptVisitor(actionVisitor); CreateFile(OutputFilePath, GenerateJSON(featuresToFormat)); }
public void Format(Body body, FeatureDirectoryTreeNode featureDirectoryTreeNode) { Feature feature = featureDirectoryTreeNode.Feature; body.InsertPageBreak(); if (configuration.HasTestResults) { TestResult testResult = nunitResults.GetFeatureResult(feature); if (testResult.WasExecuted && testResult.WasSuccessful) { body.GenerateParagraph("Passed", "Passed"); } else if (testResult.WasExecuted && !testResult.WasSuccessful) { body.GenerateParagraph("Failed", "Failed"); } } body.GenerateParagraph(feature.Name, "Heading1"); body.GenerateParagraph(feature.Description, "Normal"); foreach (IFeatureElement featureElement in feature.FeatureElements) { var scenario = featureElement as Scenario; if (scenario != null) { wordScenarioFormatter.Format(body, scenario); } var scenarioOutline = featureElement as ScenarioOutline; if (scenarioOutline != null) { wordScenarioOutlineFormatter.Format(body, scenarioOutline); } } }
private static void SetResultsAtFeatureLevel(FeatureNode featureTreeNode, ITestResults testResults) { featureTreeNode.Feature.Result = testResults.GetFeatureResult(featureTreeNode.Feature); }