Create the project

I used a class library project

Add the required libraries

Using Nuget:

  • Specflow.xunit
  • FluentAssertions
  • Microsoft.net.test.sdk

Add some features

  • Create a folder called features (for the gherkin files)
  • Create a folder called steps (for the step implementation files)

Create a feature file in features, such as test.feature, containing:

Feature:
  As a product owner
  I want to use Gherkin
  So that I convey system intent to my dear developers

Add some acceptance criteria:

Scenario: A use case
  Given I have some gherkin
  When I execute it
  Then the product owner is happy

Now build the project. Some magickery will cause some files to be created, to support SpecFlow.

Implement a stub step

To let SpecFlow know where to create the implementation for the steps:

  • Create a class such as TestSteps inside the steps folder:
namespace xxx
{
   [TechTalk.Specflow.Binding]
   public class TestSteps
   {
   }
}

Link the Gherkin to C#

Now go back to the feature file and option-enter the squiggly line on all the steps. Rider will create the step stubs in the TestSteps file.

Voila!