I cannot get specflow's code behind files to regenerate

那年仲夏 提交于 2019-12-08 08:50:40

问题


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.


回答1:


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.




回答2:


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.




回答3:


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.

  1. Remove 'specflowsinglefilegenerator' custom tool reference from all of your *.feature files (Before...) (After...)
  2. Delete the current *.feature.cs files which correspond to your *.feature files
  3. 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,
  4. Add a specflow.json file to the project which contains your specflow feature files (*.feature)
  5. Now try rebuilding your solution. On rebuild your *.feature.cs files should get auto-generated.


来源:https://stackoverflow.com/questions/57684709/i-cannot-get-specflows-code-behind-files-to-regenerate

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!