Reputation: 631
When I edit a specflow feature file test, it doesn't update the code-behind file.
When I try to manually regenerate the code-behind files by right-clicking the project and choosing 'Regenerate Feature Files'
I get an error:
Error: cannot find custom tool 'specflowsinglefilegenerator' on this system
I've discovered that this usually means I don't have Specflow
Extention installed. However, when I look in Extensions and Update in Visual studio I can see that 'Specflow for Visual Studio 2017'
is installed.
If anyone knows what I can do that would be very helpful. This started when I re-cloned the repository into a new folder.
I have also tried clean and rebuild. Closing visual studio. Uninstalling and reinstalling Specflow Extention. Switching from visual studio from 2019 to 2017. Restarting my computer. Updating specflow. Deleting the specflow cache file and forcing the files to regenerate. I still have no changes to the code-behind file.
Upvotes: 18
Views: 24175
Reputation: 25877
For using legacy Specflow v2.4.1
with MSTest, here is what all you need to do:
Set this option in Visual Studio:
Set the CustomTool
property for your feature files:
Have below tag in App.Config of your test project:
<specFlow>
<unitTestProvider name="MsTest" />
</specFlow>
Add reference to Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll as shown in below snapshot:
Make sure you've below two nuget packages added in your test project:
Then try to regerate feature files. If this doesn't work try above steps again after taking below steps:
bin
and obj
folders.Below links are good read to know about specflow code generation stuff:
https://docs.specflow.org/projects/specflow/en/latest/Tools/Generate-Tests-From-MsBuild.html https://docs.specflow.org/projects/specflow/en/latest/Installation/Unit-Test-Providers.html
Upvotes: 1
Reputation: 1897
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.
Upvotes: 3
Reputation: 3253
I had the same issue . And when I upgraded my specflow to 3.0.213 , feature.cs and tests were not generated. Then I used this MSBUild example with latest specflow to generate feature.cs and tests in test explorer. It uses MSTest as test runner.
Upvotes: 1
Reputation: 631
In Visual studio, I chose: Tools > Options > Specflow. Then set Enable SpecFlowSingleFileGenerator Custom Tool to True.
This is a legacy setting, however, and I want to try and find a way to use MSBuild.
Upvotes: 35