6. Specflow


Specflow isn’t a unit test framework, but it can help you to write a readable test.

SpecFlow allows you to write you test as a test scenario, and it will convert those scenario’s into unit test. In order to use it, create a test project and then install the following NuGet packages:

  • SpecFlow SpecRun.SpecFlow

Depending on your test framework of choice, also install one of the following packages:

  • SpecFlow.MsTest SpecFlow.NUnit
  • SpecFlow.xUnit
  • SpecFlow also need the SpecFlow for Visual Studio 2019 extensions to be installed
  • Add a new SpecFlow Feature File to your test project and write you test scenario.

For example: Feature:


       In order to avoid silly mistakes 

       As a math idiot 

       I want to be told the sum of two numbers 



Scenario: Add two numbers 

       Given I have entered 50 into the calculator 

       And I have also entered 70 into the calculator
When I press add Then the result should be 120 on the screen

When you save this file/build your project if will generate a *.cs file for this test scenario.

See https://specflow.org/getting-started/ for more information.