Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Specflow error: Force regenerate steps possible?

Tags:

specflow

Is it possible to "force" regenerate step definitions for a specflow feature file? I have created this feature file but cannot generate all steps. Am getting a message that all steps are already bound but when I run the test, I get an error that the same steps are not bound. I have cleared everything and recreated both feature and step definition but now I cant event generate ALL the steps because specflow says they are bound already.

like image 519
Ibexy I Avatar asked Jun 18 '13 11:06

Ibexy I


People also ask

Could not find SpecFlowSingleFileGenerator?

Cannot find custom tool SpecFlowSingleFileGenerator If Visual Studio displays the error message Cannot find custom tool 'SpecFlowSingleFileGenerator' on this system. when right-clicking on a feature file and selecting Run Custom Tool , make sure the SpecFlow extension is installed and enabled.

How do you regenerate SpecFlow 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.

What is binding in SpecFlow?

The automation that connects the specification to the application interface has to be developed first. The automation that connects the Gherkin specifications to source code is called a binding. The binding classes and methods can be defined in the SpecFlow project or in external binding assemblies.

How do I generate step definitions in SpecFlow Visual Studio?

Right-click in the editor and select Generate Step Definitions from the menu. A dialog is displayed with a list of the steps in your feature file. Use the check boxes to determine which steps to generate skeleton code for.


2 Answers

SpecFlow creates a .cache file in your Temp folder that holds these bindings to speed things up. If that file gets out of whack, you can delete it:

  1. Exit Visual Studio.
  2. Open Windows Explorer.
  3. In the address bar, type %TEMP% and hit Enter to go to your temp folder.
  4. Find the files whose names start with "specflow-stepmap-YourProjectName" with a .cache extension.
  5. Delete those files.
  6. Start Visual Studio again.

If you do this, it'll take a little time for SpecFlow to regenerate the bindings. Until this is done, if you right-click on a step and select "Go To Step Definition", Visual Studio will reply "Step bindings are still being analyzed. Please wait."

I most commonly use this for the opposite case, where SpecFlow shows that nothing is bound even though the steps exist. But I think it's likely to work for your case as well.

like image 88
Ryan Lundy Avatar answered Oct 09 '22 23:10

Ryan Lundy


Right-click the .feature file and chose "Run Custom Tool". That will rerun the SpecFlowSingleFileGenerator that generates the code-behind in the test framework of your choice.

like image 23
Marcus Hammarberg Avatar answered Oct 10 '22 00:10

Marcus Hammarberg