public XElement Format(Scenario scenario, int id) { var header = new XElement( this.xmlns + "div", new XAttribute("class", "scenario-heading"), new XElement(this.xmlns + "h2", scenario.Name)); var tags = RetrieveTags(scenario); if (tags.Length > 0) { var paragraph = new XElement(this.xmlns + "p", CreateTagElements(tags.OrderBy(t => t).ToArray(), this.xmlns)); paragraph.Add(new XAttribute("class", "tags")); header.Add(paragraph); } header.Add(this.htmlDescriptionFormatter.Format(scenario.Description)); return new XElement( this.xmlns + "li", new XAttribute("class", "scenario"), this.htmlImageResultFormatter.Format(scenario), header, new XElement( this.xmlns + "div", new XAttribute("class", "steps"), new XElement( this.xmlns + "ul", scenario.Steps.Select(step => this.htmlStepFormatter.Format(step))))); }
public void Then_feature_without_background_adds_first_scenario_on_correct_row() { var excelFeatureFormatter = Container.Resolve<ExcelFeatureFormatter>(); var feature = new Feature { Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature", }; var scenario = new Scenario { Name = "Test Scenario", Description = "In order to test this scenario,\nAs a developer\nI want to test this scenario" }; var given = new Step { NativeKeyword = "Given", Name = "a precondition" }; scenario.Steps = new List<Step>(new[] { given }); feature.AddFeatureElement(scenario); using (var workbook = new XLWorkbook()) { IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); excelFeatureFormatter.Format(worksheet, feature); Check.That(worksheet.Cell("B4").Value).IsEqualTo(scenario.Name); Check.That(worksheet.Cell("C5").Value).IsEqualTo(scenario.Description); Check.That(worksheet.Cell("D6").Value).IsEqualTo(given.Name); } }
public void Format(Body body, Scenario background) { var headerParagraph = new Paragraph(new ParagraphProperties(new ParagraphStyleId { Val = "Heading2" })); var backgroundKeyword = GetLocalizedBackgroundKeyword(); headerParagraph.Append(new Run(new RunProperties(new Bold()), new Text(backgroundKeyword))); var table = new Table(); table.Append(GenerateTableProperties()); var row = new TableRow(); var cell = new TableCell(); cell.Append(headerParagraph); foreach (var descriptionSentence in WordDescriptionFormatter.SplitDescription(background.Description)) { cell.Append(CreateNormalParagraph(descriptionSentence)); } foreach (var step in background.Steps) { cell.Append(WordStepFormatter.GenerateStepParagraph(step)); if (step.TableArgument != null) { cell.Append(this.wordTableFormatter.CreateWordTableFromPicklesTable(step.TableArgument)); } } cell.Append(CreateNormalParagraph("")); // Is there a better way to generate a new empty line? row.Append(cell); table.Append(row); body.Append(table); }
public void ThenCanRenderTags() { var configuration = Container.Resolve<Configuration>(); var scenario = new Scenario { Name = "A Scenario", Description = @"This scenario has tags", Tags = { "tag1", "tag2" } }; var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>(); XElement featureElement = htmlFeatureFormatter.Format(scenario, 1); XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div"); Check.That(header).IsNotNull(); Check.That(header).IsNamed("div"); Check.That(header).IsInNamespace("http://www.w3.org/1999/xhtml"); Check.That(header).HasAttribute("class", "scenario-heading"); Check.That(header.Elements().Count()).IsEqualTo(3); Check.That(header.Elements().ElementAt(0)).IsNamed("h2"); Check.That(header.Elements().ElementAt(1)).IsNamed("p"); Check.That(header.Elements().ElementAt(2)).IsNamed("div"); var tagsParagraph = header.Elements().ElementAt(1); Check.That(tagsParagraph.ToString()).IsEqualTo( @"<p class=""tags"" xmlns=""http://www.w3.org/1999/xhtml"">Tags: <span>tag1</span>, <span>tag2</span></p>"); }
public void Then_feature_with_background_is_added_successfully() { var excelFeatureFormatter = Container.Resolve<ExcelFeatureFormatter>(); var feature = new Feature { Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature", }; var background = new Scenario { Name = "Test Background Scenario", Description = "In order to test this background,\nAs a developer\nI want to test this background" }; var given = new Step { NativeKeyword = "Given", Name = "a precondition" }; background.Steps = new List<Step>(new[] { given }); feature.AddBackground(background); using (var workbook = new XLWorkbook()) { IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); excelFeatureFormatter.Format(worksheet, feature); Check.That(worksheet.Cell("B4").Value).IsEqualTo(background.Name); Check.That(worksheet.Cell("C5").Value).IsEqualTo(background.Description); Check.That(worksheet.Cell("D6").Value).IsEqualTo(given.Name); } }
public void Format(Body body, Scenario scenario) { if (this.configuration.HasTestResults) { TestResult 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 (Step step in scenario.Steps) { this.wordStepFormatter.Format(body, step); } }
public void ThenSingleScenarioWithStepsAddedSuccessfully() { var excelScenarioFormatter = Container.Resolve<ExcelScenarioFormatter>(); var scenario = new Scenario { Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature" }; var given = new Step {NativeKeyword = "Given", Name = "a precondition"}; var when = new Step {NativeKeyword = "When", Name = "an event occurs"}; var then = new Step {NativeKeyword = "Then", Name = "a postcondition"}; scenario.Steps = new List<Step>(new[] {given, when, then}); using (var workbook = new XLWorkbook()) { IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); int row = 3; excelScenarioFormatter.Format(worksheet, scenario, ref row); Check.That(worksheet.Cell("B3").Value).IsEqualTo(scenario.Name); Check.That(worksheet.Cell("C4").Value).IsEqualTo(scenario.Description); Check.That(row).IsEqualTo(8); } }
public override TestResult GetScenarioResult(Scenario scenario) { XElement scenarioElement = this.GetScenarioElement(scenario); return scenarioElement != null ? this.GetResultFromElement(scenarioElement) : TestResult.Inconclusive; }
public void Map_SomeScenario_ReturnsSomeJsonScenario() { var scenario = new Scenario(); var mapper = CreateMapper(); JsonScenario actual = mapper.Map(scenario); Check.That(actual).IsNotNull(); }
public void Map_NoTags_ReturnsEmptyListOfTags() { var scenario = new Scenario { Tags = null }; var mapper = CreateMapper(); JsonScenario actual = mapper.Map(scenario); Check.That(actual.Tags.Count).IsEqualTo(0); }
public void Map_NoSteps_ReturnsEmtpyListOfSteps() { var scenario = new Scenario { Steps = null }; var mapper = CreateMapper(); JsonScenario actual = mapper.Map(scenario); Check.That(actual.Steps.Count).IsEqualTo(0); }
public XElement Format(Scenario scenario) { if (this.configuration.HasTestResults) { TestResult scenarioResult = this.results.GetScenarioResult(scenario); return this.BuildImageElement(scenarioResult); } return null; }
public TestResult GetScenarioResult(Scenario scenario) { Parser.JsonResult.Element cucumberScenario = null; var cucumberFeature = this.GetFeatureElement(scenario.Feature); if (cucumberFeature != null) { cucumberScenario = cucumberFeature.elements.FirstOrDefault(x => x.name == scenario.Name); } return this.GetResultFromScenario(cucumberScenario); }
private Guid GetScenarioExecutionId(Scenario queriedScenario) { var idString = (from scenario in this.AllScenariosInResultFile() let properties = PropertiesOf(scenario) where properties != null where FeatureNamePropertyExistsWith(queriedScenario.Feature.Name, among: properties) where NameOf(scenario) == queriedScenario.Name select ScenarioExecutionIdStringOf(scenario)).FirstOrDefault(); return !string.IsNullOrEmpty(idString) ? new Guid(idString) : Guid.Empty; }
public TestResult GetScenarioResult(Scenario scenario) { XElement featureElement = this.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 this.GetResultFromElement(scenarioElement); }
protected override XElement GetScenarioElement(Scenario scenario) { XElement featureElement = this.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 scenarioElement; }
public TestResult GetScenarioResult(Scenario scenario) { XElement featureElement = this.GetFeatureElement(scenario.Feature); XElement scenarioElement = null; if (featureElement != null) { scenarioElement = featureElement .Descendants("test-case") .FirstOrDefault( ts => ts.Elements("properties").Elements("property") .Any(p => p.Attribute("name").Value == "Description" && p.Attribute("value").Value == scenario.Name)); } return this.GetResultFromElement(scenarioElement); }
public JsonScenario Map(Scenario scenario) { if (scenario == null) { return null; } return new JsonScenario { Steps = (scenario.Steps ?? new List<Step>()).Select(this.stepMapper.Map).ToList(), Tags = (scenario.Tags ?? new List<string>()).ToList(), Name = scenario.Name, Slug = scenario.Slug, Description = scenario.Description, Result = this.resultMapper.Map(scenario.Result), }; }
private XElement FormatLinkButton(Scenario scenarioOutline) { if (string.IsNullOrEmpty(scenarioOutline.Slug)) { return null; } return new XElement( this.xmlns + "a", new XAttribute("class", "scenario-link"), new XAttribute("href", $"javascript:showImageLink('{scenarioOutline.Slug}')"), new XAttribute("title", "Copy scenario link to clipboard."), new XElement( this.xmlns + "i", new XAttribute("class", "icon-link"), " ")); }
public override TestResult GetScenarioResult(Scenario scenario) { var specRunFeature = this.FindSpecRunFeature(scenario.Feature); if (specRunFeature == null) { return TestResult.Inconclusive; } var specRunScenario = FindSpecRunScenario(scenario, specRunFeature); if (specRunScenario == null) { return TestResult.Inconclusive; } return StringToTestResult(specRunScenario.Result); }
protected override XElement GetScenarioElement(Scenario scenario) { XElement featureElement = this.GetFeatureElement(scenario.Feature); XElement scenarioElement = null; if (featureElement != null) { scenarioElement = featureElement.Descendants("test-case") .FirstOrDefault( ts => ts.Elements("properties") .Elements("property") .Any( p => IsDescriptionAttribute(p) && p.Attribute("value").Value == scenario.Name)); } return scenarioElement; }
public void ThenSingleScenarioAddedSuccessfully() { var excelScenarioFormatter = Container.Resolve<ExcelScenarioFormatter>(); var scenario = new Scenario { Name = "Test Feature", Description = "In order to test this feature,\nAs a developer\nI want to test this feature" }; using (var workbook = new XLWorkbook()) { IXLWorksheet worksheet = workbook.AddWorksheet("SHEET1"); int row = 3; excelScenarioFormatter.Format(worksheet, scenario, ref row); Check.That(worksheet.Cell("B3").Value).IsEqualTo(scenario.Name); Check.That(worksheet.Cell("C4").Value).IsEqualTo(scenario.Description); Check.That(row).IsEqualTo(5); } }
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 = this.testResults.GetScenarioResult(scenario); if (this.configuration.HasTestResults && results.WasExecuted) { worksheet.Cell(originalRow, "B").Style.Fill.SetBackgroundColor( results.WasSuccessful ? XLColor.AppleGreen : XLColor.CandyAppleRed); } foreach (Step step in scenario.Steps) { this.excelStepFormatter.Format(worksheet, step, ref row); } }
public TestResult GetScenarioResult(Scenario scenario) { if (this.specRunFeatures == null) { return(TestResult.Inconclusive); } var specRunFeature = this.FindSpecRunFeature(scenario.Feature); if (specRunFeature == null) { return(TestResult.Inconclusive); } var specRunScenario = FindSpecRunScenario(scenario, specRunFeature); if (specRunScenario == null) { return(TestResult.Inconclusive); } return(StringToTestResult(specRunScenario.Result)); }
public void NoTags() { var configuration = Container.Resolve<Configuration>(); var scenario = new Scenario { Name = "A Scenario", Description = @"This scenario has no tags", Tags = { } }; var htmlFeatureFormatter = Container.Resolve<HtmlScenarioFormatter>(); XElement featureElement = htmlFeatureFormatter.Format(scenario, 1); XElement header = featureElement.Elements().FirstOrDefault(element => element.Name.LocalName == "div"); Check.That(header).IsNotNull(); Check.That(header).IsNamed("div"); Check.That(header).IsInNamespace("http://www.w3.org/1999/xhtml"); Check.That(header).HasAttribute("class", "scenario-heading"); Check.That(header.Elements().Count()).IsEqualTo(2); Check.That(header.Elements().ElementAt(0)).IsNamed("h2"); Check.That(header.Elements().ElementAt(1)).IsNamed("div"); }
private static Parser.SpecRun.Scenario FindSpecRunScenario(Scenario scenario, Parser.SpecRun.Feature specRunFeature) { Parser.SpecRun.Scenario result = specRunFeature.Scenarios.FirstOrDefault(d => d.Title.Equals(scenario.Name)); return(result); }
private XElement GetScenarioElement(Scenario scenario) { XElement featureElement = this.GetFeatureElement(scenario.Feature); IEnumerable<XElement> 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(); }
private static string[] RetrieveTags(Scenario scenario) { if (scenario == null) { return new string[0]; } if (scenario.Feature == null) { return scenario.Tags.ToArray(); } return scenario.Feature.Tags.Concat(scenario.Tags).ToArray(); }
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); result.ShouldEqual(TestResult.Inconclusive); }
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); result.ShouldEqual(TestResult.Failed); }
private ScenarioBaseAndBackground GetCucumberScenario(Scenario scenario) { Element cucumberScenario = null; var cucumberFeature = this.GetCucumberFeature(scenario.Feature); if (cucumberFeature?.Feature != null) { cucumberScenario = cucumberFeature.Feature.elements?.FirstOrDefault(x => x.name == scenario.Name); } return new ScenarioBaseAndBackground(cucumberScenario, cucumberFeature?.Background); }
public override TestResult GetScenarioResult(Scenario scenario) { var cucumberScenario = this.GetCucumberScenario(scenario); return this.GetResultFromScenario(cucumberScenario.ScenarioBase, cucumberScenario.Background); }