Know where you step–generate a step definition report with SpecFlow

· December 16, 2010

In my recent ventures into DOS-country and the SpecFlow.exe I noticed one last flag or subcommand that the SpecFlow.exe accepts; stepdefinitionreport. This subcommand will go through all your features and see which step definitions are called, how many times they are called and also if there is any step definitions that isn’t called at all. OK – that sounds real good, but for the life for me I couldn’t get it to work.

But since the source is open and available from gitHub.com I simply pulled a version down and tried to debug the code. And before long I found the solution. SpecFlow (now 2010-12-16) uses .NET framework 3.5, but my specifications were written using .NET 4.0. There are some reflection going on inside the step definition report code and that doesn’t work very well (loading assemblies from different framework versions).

OK – I simply change the .NET framework to 4.0 and compiled myself a local version and tried the command against that version. And … it worked! Here is the command I used:

SpecFlow.exe stepdefinitionreport Specs\Specs.csproj

That produces a report as follows:

step definition example report

The report could be very useful I think especially if you have a large project with loads of steps.

I updated my code and pushed it here.

Twitter, Facebook