public void CanGenerateOutput() { var scenario = new SbeScenario { Title = "Scenario Title", Outcome = Outcome.Passed }; var feature = new SbeFeature(title: "Feature Title", scenarios: new[] { scenario }); var collectedTests = new SbeAssembly[] { new SbeAssembly( name: "some.strange.assembly", epics: new[] { new SbeEpic(name: "Some Epic", features: new[] { feature }) }) }; string outputFileName = null; string outputContent = null; var generator = new JsonSummaryGenerator((file, json) => { outputFileName = file; outputContent = json; }); generator.Generate(collectedTests); Assert.That(outputFileName, Is.EqualTo("\\some.strange.assembly.summary.sbe.json"), "FileName"); var output = JObject.Parse(outputContent); Assert.That(output["epics"].HasValues, Is.True, "Should contain epics"); }
internal string FeatureHtml(SbeFeature feature) { var parser = new Parser(); using (var reader = new StringReader(feature.FeatureText)) { var doc = parser.Parse(reader); return(FeatureHtml(doc, feature)); } }
private static SbeFeature GetCurrentFeature(SbeEpic epic, SpecflowContextWrapper specflowContext) { var title = specflowContext.FeatureTitle; if (!epic.Features.TryGetValue(title, out SbeFeature feature)) { feature = new SbeFeature { Title = specflowContext.FeatureTitle, Tags = specflowContext.FeatureTags, }; epic.Features.Add(title, feature); } return(feature); }
private void GenerateHtmlForParsedFeature(GherkinDocument document, SbeFeature feature, StringBuilder sb) { foreach (var child in document.Feature.Children) { if (child is Background) { BackgroundHtml(child as Background, sb); } else if (child is ScenarioDefinition) { ScenarioHtml(child as ScenarioDefinition, sb, feature.Scenarios); } else { throw new NotSupportedException($"Type {child.GetType().FullName} is not a supported child of a feature."); } } }
private string FeatureHtml(GherkinDocument document, SbeFeature feature) { var sb = new StringBuilder(); sb.AppendLine("<div class=\"feature\">"); TagsHtml(sb, document.Feature.Tags); sb.AppendLine($@"<table class=""feature-title""><tr><td>{GenerateStatusImageTag(feature.GetOutcome())}</td> <td class=""text"">{document.Feature.Keyword}: {HtmlEncode(document.Feature.Name)}</td></tr></table>"); sb.AppendLine($"<p>{AddLineBreaks(HtmlEncode(document.Feature.Description))}</p>"); GenerateHtmlForParsedFeature(document, feature, sb); sb.AppendLine("</div>"); return(sb.ToString()); }
public void CanGeneratePdf() { var scenario = new SbeScenario { Title = "Scenario Title", Outcome = Outcome.Passed }; var feature = new SbeFeature(title: "Feature Title", scenarios: new[] { scenario }); feature.FeatureText = @"@current Feature: Implemented Feature Some description Scenario: Add two numbers for implemented calculator Given I have entered 50 into the calculator And I have entered 70 into the calculator When I press add Then the result should be 120 on the screen" ; var collectedTests = new SbeAssembly[] { new SbeAssembly( name: "some.strange.assembly", epics: new[] { new SbeEpic(name: "Some Epic", features: new[] { feature }) }) }; string outputFileName = null; byte[] outputContent = null; var generator = new PdfGenerator("testing", OutputFilter.All, (file, bytes) => { outputFileName = file; outputContent = bytes; }); generator.Generate(collectedTests); Assert.That(outputFileName, Is.EqualTo("\\some.strange.assembly.testing.sbe.pdf"), "FileName"); var firstFourBytes = Convert.ToBase64String(outputContent.Take(4).ToArray()); Assert.That(firstFourBytes, Is.EqualTo("JVBERg==")); }
private void WriteFeature(SbeFeature feature) { xml.StartElement("feature"); xml.AttributeString("scenarioCount", feature.Scenarios.Count.ToString()); xml.AttributeString("scenarioSuccessCount", feature.Scenarios.Count(x => x.Success()).ToString()); xml.AttributeString("success", feature.Success().ToString()); xml.CDataElementString("title", feature.Title); if (showFeatureTexts) { xml.CDataElementString("featureText", feature.FeatureText); } WriteTags(feature.Tags); xml.StartElement("scenarios"); foreach (var scenario in feature.Scenarios) { WriteScenario(scenario); } xml.EndElement(); xml.EndElement(); }
internal bool IncludeFeature(SbeFeature feature) { return(filter == Filter.All || (filter == Filter.CurrentIteration && feature.IsCurrentIteration()) || (filter == Filter.AllImplemented && feature.IsImplemented())); }