Home > BDD, C#, TDD, Test Automation > Test Execution Report in SpecFlow

Test Execution Report in SpecFlow

It would be very good to generate test reports related to Acceptance tests for satisfying our requirements and providing the test statuses to Customers & Project Managers. This report provides a formatted HTML report of a test execution. The report contains a summary about the executed tests and the result and also a detailed report for the individual scenario executions.

NUnit Test Execution Report

Let me create a Test Execution Report for my previous blog on SpecFlow. In order to generate this report you have to execute the acceptance tests with the nunit-console runner. This tool generates an XML summary about the test executions. To have the detailed scenario execution traces visible, you also need to capture the test output using the /out and the /labels options as it can be seen in the following example.

Step 1:

nunit-console.exe /labels /out=TestResult.txt /xml=TestResult.xml bin\Debug\SpecflowTest.dll

The two generated file can be used to invoke the SpecFlow report generation. If you use the output file names shown above it is enough to specify the project file path containing the feature files.

Step 2:

specflow.exe nunitexecutionreport SpecflowTest.csproj /out:MyResult.html

Step 1 is already executed as we are running the tests using the NUnit GUI and this automatically generates a TestResult.xml file in the bin\Debug folder as shown in the snapshot below:


Now, let me jump to the Step 2. Step 2 can be executed by using the External tools in the Visual Studio.

  • Go to Tools -> External Tools
  • Click on the ‘Add’ button in the ‘External Tools’ window
  • Input a Title (say in my case ‘SpecFlow Test Result’)
  • Input the location of SpecFlow application in the ‘Command’ field (say in my case ‘C:\Program Files (x86)\TechTalk\SpecFlow\specflow.exe’)
  • Input the argument in the ‘Arguments’ field (say in my case ‘nunitexecutionreport SpecflowTest.csproj /xmlTestResult:bin\debug\TestResult.xml’)
  • Input the directory info in ‘Initial directory’ field (say in my case ‘$(ProjectDir)’)
  • Set the ‘Close on exit’ checkbox and hit the ‘Apply’ & ‘OK’ buttons. A new option ‘SpecFlow Test Result’ under the ‘Tools’ menu.
Generating the Test Report
  • Debug the project and run the test using NUnit GUI window.
  • Click on the option ‘SpecFlow Test Result’ under the ‘Tools’ menu.
  • Open the ‘TestResult.html’ file present in the ‘Projects’ folder using the browser as in the snapshot below.
  • Create a short-cut to the ‘TestResult.html’ file by adding the file to the Visual Studio Solution Explorer for quick viewing as in the snapshot below.
  1. September 8, 2012 at 4:59 pm

    I am truly pleased to read this website posts which
    consists of lots of valuable facts, thanks for providing such statistics.

  2. Irina
    October 8, 2012 at 1:36 pm

    Thank you! It is a very useful article!

  3. January 24, 2013 at 4:53 am

    A formidable share, I just given this onto a colleague who was doing a bit of
    analysis on this. And he in truth purchased me breakfast as a result of I
    found it for him.. smile. So let me reword that: Thnx for the treat!
    However yeah Thanks for spending the time to discuss this, I really feel strongly about it and love reading extra on this topic. If possible, as you develop into
    experience, would you mind updating your blog with extra details? It is highly useful for me. Big thumb up for this weblog publish!

  4. Yvette
    June 17, 2013 at 3:45 pm

    Hi Anoop,
    I read your article, quite interesting, im a newbee and developing automation using Selenium – nunit for C#. I am not sure if its manadotory to use Specflow within the framework. However im looking to incorporate page object pattern. The above test results using SpecFlow is awesome. But is there a way we coudl just such a test with just the Testresult.xml using the External tool without involving SpecFlow. Im little confused here. Would you be able to provide best suggestions please?

  5. Dmitry
    September 23, 2014 at 5:16 pm

    I can’t understand where should I paste this ‘nunit-console.exe /labels /out=TestResult.txt /xml=TestResult.xml bin\Debug\SpecflowTest.dll’ command? It’s a little confusing for me.
    And the second command ‘specflow.exe nunitexecutionreport SpecflowTest.csproj /out:MyResult.html’ too. Could you please help me with this?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: