Automated testing using SpecFlow

SpecFlow Installation and Setup

What is SpecFlow?

SpecFlow is an open-source .NET tool for automated testing that lets you write specifications using 100%-Cucumber-compatible Gherkin syntax, and has a number of advantages over Cucumber itself.

  • It integrates with Visual Studio.
  • It gives complete VS debugger support, so you can set breakpoints on Given/When/Then lines in your .feature files and step through their execution.
  • You can implement your step definitions in any .NET language.
  • When you compile a project containing SpecFlow feature files, the output is an NUnit test assembly, so you can use your favourite NUnit-compatible test runner or existing CI infrastructure to run the specifications with no additional configuration.


  • Installation involves installing IDE Integration and Setting up project to work
  • For VS 2012 and VS 2010, use extension manager to search “SpecFlow”
  • Refer the screenshots below.





Setup SpecFlow Project using NUGET

The SpecFlow tests are usually placed into one or more separate project in the solution: The easiest and most convenient way to setup these projects is to use NuGet package: SpecFlow or one of the specific helper packages, like SpecFlow.NUnit or SpecRun.SpecFlow.

  • Create a project

Since SpecFlow can use different unit testing frameworks to execute the SpecFlow tests, the SpecFlow projects have to be either Test Projects (in case of MsTest) or a simple Class Libraries.

  • Add reference for the SpecFlow runtime

SpecFlow projects need the TechTalk.SpecFlow.dll in order to compile. You can setup this by installing NuGet package: SpecFlow or one of the specific helper packages, like SpecFlow.NUnit or SpecRun.SpecFlow. The helper packages group all necessary dependencies and apply the necessary configuration.

  • Configure SpecFlow project

If you have used one of the helper NuGet packages you don’t need to configure anything. If you have used the SpecFlow package or want to fine tune SpecFlow, you need to change the settings in the App.config file.

  • Add your first feature file

Your project is ready to use SpecFlow. You can add the first feature files (with Add / New Item in Visual Studio for example) and implement your applications in Specification by Example (Behavior Driven Development (BDD),Acceptance Test Driven Development (ATDD)) style.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.