August 31, 2018

SpecFlow Step Definition Report

The SpecFlow runtime comes with a little known command line utility aptly named specflow.exe. You can find it in the tools directory in the SpecFlow NuGet package (ex: [project]/packages/SpecFlow.2.3.2/tools). This humble tool can be used to regenerate SpecFlow unit test classes, create test execution reports for NUnit and MSTest, and generate a step definition report. The most useful of these is the step definition report.

As the number of features grows, scenarios and bindings are going to get lost in the day-to-day scrum of software development. The team will define scenarios that are added to a feature file but are never bound. The converse is true as well. Scenarios are removed when they no longer apply, but their bindings stick around. That’s where the step definition report comes in. It helps you to find unbound scenarios and unused bindings, so you can keep your code base tidy.

Generate the Report

The step definition report can be easily integrated into your CI process. The report is generated by invoking specflow.exe with the stepdefinitionreport command.

1
specflow.exe stepdefinitionreport SpecFlowTalk.csproj /BinFolder:bin/debug

By default, the result is saved to StepDefinitionReport.html, but you can change that with the /out parameter. Check out the SpecFlow reporting documentation for more options.

Report Details

The report below provides binding and usage details for a sample SpecFlow project. A red background indicates code not used in any scenarios. A yellow background indicates scenarios with no automation. You could run the step definition report as part of your CI process and save the result as a build artifact. Then engineers could regularly review the report and create stories to clean up the scenarios and bindings. The goal is to have no yellow or red rows.

Click here for a full page view of the report.


If you’re not using this report, I encourage you to check it out. It makes a useful addition to your CI process.

© Joe Buschmann 2020