Running SpecFlow Reports from within Visual Studio

So, I’ve been loving SpecFlow for the past few months. There is a sweet command-line tool that will generate you a nice HTML report to show which Specs are passing etc. It’s a bit cumbersome to use (I’ve blogged about it’s usage before); I have managed to configure it to run inside of Visual Studio, and thought it might be useful for others.

This will run nunit tests, run specflow report against the nunit output,  and finally open the test generation file in the default browser.

You can configure External Tools from the Tools menu in Visual Studio.

Select the following options:

  • Command – C:\Source\Scripts\run_specflow_report.bat
  • Arguments – $(TargetName)$(TargetExt) $(ProjectDir)$(ProjectFileName) $(BinDir)TestResult.xml
  • Initial Directory – $(BinDir)
  • Check “Use Output Window”

You also need to create a batch file with the name specified in the Command field. Something along the lines of:

@echo off
nunit-console %1
if NOT %errorlevel% == 0 (
	echo "Error running tests - %errorlevel%"
	GOTO :exit
)
specflow.exe nunitexecutionreport %2 /xmlTestResult:%3
if NOT %errorlevel% == 0 (
	echo "Error generating report - %errorlevel%"
	GOTO :exit
)
if %errorlevel% ==0 TestResult.html
:exit

The only down-side is that you have to select the Specs project when you run the external tool. If you have a work-around, I’d love to see it. Hope that helps someone.

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)
This entry was posted in SpecFlow. Bookmark the permalink.