public void Format(XElement parentElement, Scenario scenario) { var section = new XElement("section", new XElement("title", scenario.Name)); if (this.configuration.HasTestResults) { var testResult = this.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 (var step in scenario.Steps) { this.ditaStepFormatter.Format(section, step); } parentElement.Add(section); }
public void ThenCanReadScenarioResultSuccessfully() { // Write out the embedded test results file using (var input = new StreamReader(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Pickles.Test." + RESULTS_FILE_NAME))) using (var output = new StreamWriter(RESULTS_FILE_NAME)) { output.Write(input.ReadToEnd()); } var configuration = Kernel.Get<Configuration>(); configuration.TestResultsFile = new FileInfo(RESULTS_FILE_NAME); var results = Kernel.Get<XUnitResults>(); var feature = new Feature { Name = "Addition" }; var scenario1 = new Scenario { Name = "Add two numbers", Feature = feature }; var result1 = results.GetScenarioResult(scenario1); result1.WasExecuted.ShouldBeTrue(); result1.WasSuccessful.ShouldBeTrue(); var scenario2 = new Scenario { Name = "Fail to add two numbers", Feature = feature }; var result2 = results.GetScenarioResult(scenario2); result2.WasExecuted.ShouldBeTrue(); result2.WasSuccessful.ShouldBeFalse(); }
public void ThenCanReadBackgroundResultSuccessfully() { var background = new Scenario {Name = "Background", Feature = _feature}; _feature.AddBackground(background); TestResult result = _results.GetScenarioResult(background); result.WasExecuted.ShouldBeFalse(); result.WasSuccessful.ShouldBeFalse(); }
public XElement Format(Scenario scenario) { if (configuration.HasTestFrameworkResults) { TestResult scenarioResult = this.results.GetScenarioResult(scenario); if (!scenarioResult.WasExecuted || !scenarioResult.IsSuccessful) return null; return BuildImageElement(scenarioResult); } return null; }
private XElement GetScenarioElement(Scenario scenario) { var featureElement = GetFeatureElement(scenario.Feature); var scenarioQuery = from test in featureElement.Descendants("test") from trait in test.Descendants("traits").Descendants("trait") where trait.Attribute("name").Value == "Description" && trait.Attribute("value").Value == scenario.Name select test; return scenarioQuery.FirstOrDefault(); }
public TestResult GetScenarioResult(Scenario scenario) { var featureElement = GetFeatureElement(scenario.Feature); XElement scenarioElement = null; if (featureElement != null) { scenarioElement = featureElement .Descendants("test-case") .Where(x => x.Attribute("description") != null) .FirstOrDefault(x => x.Attribute("description").Value == scenario.Name); } return GetResultFromElement(scenarioElement); }
public void ThenCanReadScenarioResultSuccessfully() { var scenario1 = new Scenario {Name = "Add two numbers", Feature = _feature}; TestResult result1 = _results.GetScenarioResult(scenario1); result1.WasExecuted.ShouldBeTrue(); result1.WasSuccessful.ShouldBeTrue(); var scenario2 = new Scenario {Name = "Fail to add two numbers", Feature = _feature}; TestResult result2 = _results.GetScenarioResult(scenario2); result2.WasExecuted.ShouldBeTrue(); result2.WasSuccessful.ShouldBeFalse(); }
private Guid GetScenarioExecutionId(Scenario scenario) { var idString = (from unitTest in this.resultsDocument.Root.Descendants(ns + "UnitTest") let properties = unitTest.Element(ns + "Properties") let property = properties.Element(ns + "Property") let key = property.Element(ns + "Key") let value = property.Element(ns + "Value") where key.Value == "FeatureTitle" && value.Value == scenario.Feature.Name let description = unitTest.Element(ns + "Description") where description.Value == scenario.Name let id = unitTest.Element(ns + "Execution").Attribute("id").Value select id).FirstOrDefault(); return !string.IsNullOrEmpty(idString) ? new Guid(idString) : Guid.Empty; }
public XElement Format(Scenario scenario, int id) { return new XElement(xmlns + "li", new XAttribute("class", "scenario"), this.htmlImageResultFormatter.Format(scenario), new XElement(xmlns + "div", new XAttribute("class", "scenario-heading"), new XElement(xmlns + "h2", scenario.Name), this.htmlDescriptionFormatter.Format(scenario.Description) ), new XElement(xmlns + "div", new XAttribute("class", "steps"), new XElement(xmlns + "ul", scenario.Steps.Select(step => this.htmlStepFormatter.Format(step))) ) ); }
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); } }
public void Format(Body body, Scenario scenario) { if (this.configuration.HasTestResults) { var testResult = this.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 (var step in scenario.Steps) { this.wordStepFormatter.Format(body, step); } }
public TestResult GetScenarioResult(Scenario scenario) { Guid scenarioExecutionId = GetScenarioExecutionId(scenario); return GetExecutionResult(scenarioExecutionId); }
public void AddScenario(Scenario scenario) { scenario.Feature = this; this.Scenarios.Add(scenario); }
public string GetScenarioKey(Scenario scenario) { return GetScenarioKey(scenario.Feature.Name, scenario.Name); }
public XElement Format(Scenario scenario) { if (configuration.HasTestResults) { TestResult scenarioResult = results.GetScenarioResult(scenario); return scenarioResult.WasExecuted ? BuildImageElement(scenarioResult) : null; } return null; }
public TestResult GetScenarioResult(Scenario scenario) { XElement scenarioElement = GetScenarioElement(scenario); return GetResultFromElement(scenarioElement); }
public TestResult GetScenarioResult(Scenario scenario) { return new TestResult(); }
public void AddBackground(Scenario background) { background.Feature = this; Background = background; }