SpecFlow.Reporting was created to get better feedback from your automated SpecFlow testsuite. With unit tests most times reporting is only interesting for developers and testers. But when practicing BDD, the output of your automated tests might be valuable for the whole development team, management and pherhaps even end-users.
SpecFlow.Reporting makes it easy to extend SpecFlow by creating reporters which can write output in all kinds of formats and can even be enriched with additional data.
Add one or more reporters to your SpecFlow project, for example:
- Json: reports in json format example
- Plain Text: reports in plain text format example
- Xml: reports in xml format example
- WebApp: writes an interactive, responsive, client-side web application, in which users can browse and search features, scenarios and steps example
Work in progress:
- Xml.NUnit: less technical reporting in NUnit's xml output format
Make your existing StepDefinitions class inherit from SpecFlow.Reporting.ReportingStepDefinitions
Initialize and add the reporter(s) in [BeforeTestRun] and register on one of the events to get notified when something gets reported:
[Binding] public class StepDefinitions : ReportingStepDefinitions { [BeforeTestRun] public static void BeforeTestRun() { Reporters.Add(new JsonReporter()); Reporters.Add(new XmlReporter()); Reporters.Add(new PlainTextReporter()); Reporters.FinishedReport += (sender, args) => { Console.WriteLine(args.Reporter.WriteToString()); }; } }
Create a new project and add the SpecFlow.Reporting package
Add a class which inherits from SpecFlow.Reporting.Reporter and implement the WriteToStream method:
namespace SpecFlow.Reporting.MyFormat { public class MyFormatReporter : SpecFlow.Reporting.Reporter { public override void WriteToStream(Stream stream) { // // TODO: Serialize this.Report to the stream // } } }
- Xml.MsTest
- Docx
- Xlsx
- ...