These are the steps I had to take to switch from using the old, 'specflowsinglefilegenerator', to generate my *.feature.cs files to having them autoupdate whenever I build the test project.
The process is described on Specflow's website, but pictures help in understanding the process.
- Remove 'specflowsinglefilegenerator' custom tool reference from all of your *.feature files (Before...) (After...)
- Delete the current *.feature.cs files which correspond to your *.feature files
- Upgrade Specflow to 3.0.188 at least. the below is working for me. I am using NUnit for my test framework. NUnit3TestAdapter is needed for MS Test Explorer to recognize the tests. (The must haves in the below are: NUnit, NUnit3TestAdapter, Specflow, Selenium.Webdriver), Selenium.Support,
- Add the SpecFlow.Tools.MsBuild.Generation NuGet package to your project. This package is used to generate SpecFlow’s code-behind files.
- Add a specflow.json file to the project which contains your specflow feature files (*.feature)
- Now try rebuilding your solution. On rebuild your *.feature.cs files should get auto-generated.