Generating SpecFlow files in Rider

At the moment, there is no official SpecFlow support in Jetbrains .net IDE Rider. I found a way to make it more bearable. Keep in mind that it’s not a perfect solution.

After I install the SpecFlow nuget package, it downloads the SpecFlow executable that generates the .feature.cs files. Combined with the file watcher plugin, I can let the code behind files be generated. Go to Settings > Tools > File Watchers and click on the green + icon to add a custom file watcher.

Give the watcher an easy to understand name such as “SpecFlow file generation”. Select the File Type “Cucumber Scenario”. The Scope isn’t really important, because the generator will refresh all .feature.cs files. I set the Scope to “Open files”. The Program to run is situated in the folder “<solution folder>\packages\SpecFlow<version>\tools\specflow.exe”. The Arguments are “generateall $ProjectFileDir$\<TestProjectName>\<TestProjectName>.csproj”. The last setting is Output paths to refresh and it should be “$ProjectFileDir$”.


The “generateall” argument needs the test project .csproj file to see which cucumber files it needs to inspect to generated the .feature.cs files. The Output paths to refresh tells rider which folder to inspect after the program has run to detect which files are changed.

The biggest remaining problem for me is that there is no automatic steps generation. I usually start Visual Studio to generate the steps file the first time and then I manually edit the file whenever I update or add a step.

In my team, we use a Visual Studio tool to nest the .feature.cs and .steps.cs files. In Rider, there is an option to nest files. At the top right corner of the Solutions window, click the gear icon and select the File Nesting... menu item. Then click the + icon to add a new rule and add rules for both the feature.cs and .steps.cs files. It won’t nest the files in the solution, it will just display them as nested. So Visual Studio won’t nest the files, be aware of this.

It’s not perfect and official support would be better, but it’s a start. Now lets hope either Jetbrains or Specflow releases an official plugin for Rider so we can all enjoy SpecFlow as easily as it is in Visual Studio. If you want it to get here faster, start bothering both Jetbrains and SpecFlow about this.