Using SpecFlow runner to execute the feature files

Earlier we have seen how to execute the tests using Microsoft Unit Testing Framework. Now we are going to look at how to execute the scenarios using SpecFlow runner. To execute the scenarios using Specflow Runner, you will have to install below package to your project.

SpecRun.SpecFlow NuGet reference in Visual Studio

SpecRun.SpecFlow NuGet reference in Visual Studio

Once the package is installed, you should see below references in your project.

SpecFlow Runner references in visual studio project

SpecFlow Runner references in visual studio project

Ensure that app.config file contains SpecRun runner as shown in below XML file.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="specFlow" type="TechTalk.SpecFlow.Configuration.ConfigurationSectionHandler, TechTalk.SpecFlow" />
  </configSections>
  <specFlow>
   <unitTestProvider name="SpecRun" />
   <plugins>
   <add name="SpecRun" />
   </plugins>
  </specFlow>
</configuration>

Then you can add the feature file and build the solution. After that your test should appear in Test Explorer as shown in below image. You can select the scenario and execute the test.

Running feature file using SpecFlow Runner

Running feature file using SpecFlow Runner

After scenario execution, it generates the report as shown in below image.

SpecFlow report in Visual Studio

SpecFlow report in Visual Studio

SpecFlow runner report

You may also like...