Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to regenerate designer code for all SpecFlow features

I've got ~30 SpecFlow feature files, and I recently removed the Foo.feature.cs files from source control because I got sick of resolving merge conflicts in Designer Generated code.

I did not exclude or remove these files from my Visual Studio project, so Visual Studio still thinks they should be there, they are just missing on the hard disk.

Ideally I'd like to just click on a root folder and regenerate all the code behind files, but no such option exists for VS 2010 and SpecFlow 1.9. I'd even be OK with programmatically regenerating them from the command line, creating another custom tool or adding a pre-compile build event.

Is there a way to regenerate all of the the Designer generated code behind files for SpecFlow features (*.feature.cs files) without right-clicking on each .feature file and clicking "Run Custom Tool"?

like image 225
Greg Burghardt Avatar asked Sep 22 '14 13:09

Greg Burghardt


People also ask

How do you regenerate feature files?

The only way to regenerate it is to right-click on the project containing specs and choose "Regenerate Feature Files". This action regenerates all feature files, which becomes slow when a project has many feature files.

How do I update SpecFlow feature file?

make sure spec flow is installed: Tools->Extensions and updates -> SpecFlow for Visual Studio 2015. set Tools->Options->SpecFlow->Legacy->Enable SpecFlowSingleFileGenerator CustomTool = TRUE. Uninstall Tools->Extensions and updates -> SpecFlow for Visual Studio 2015. Restart Visual Studio.

What is contained in the auto generated file for the SpecFlow feature?

Q #3) What is contained in the auto-generated file for the Specflow feature? Answer: Specflow code-behind files are auto-generated files with a “. cs” extension. These files have the binding logic from Steps to the actual Step definition.

How do I uninstall SpecFlowSingleFileGenerator?

Remove all SpecFlowSingleFileGenerator custom tool entries from your feature files. Select Tools | Options | SpecFlow from the menu in Visual Studio, and set Enable SpecFlowSingleFileGenerator CustomTool to “false”.


2 Answers

You can right click on the project and choose 'regenerate feature files' to do them all at once.

like image 75
Sam Holder Avatar answered Oct 18 '22 01:10

Sam Holder


It runs much quicker from the command prompt. Go to your Specflow package tools folder and run the following command line. It also ensures the correct Specflow version is added to the files.

specflow.exe generateall <My_Testing.csproj>
like image 10
stuartdotnet Avatar answered Oct 18 '22 00:10

stuartdotnet