Is it possible to run a test from a feature file? I have like 350 testscenario's and if i need to search for them every time it takes alot of time. Can i play a test when i am in a feature file?
-
Which version of Visual Studio do you have? Which version of the SpecFlow extension for Visual Studio is installed? – Greg Burghardt Dec 03 '21 at 14:04
-
You should be able to. You should also see tests in the Test Explorer and can run a single scenario there a well. – Fran Dec 03 '21 at 16:19
-
@GregBurghardt Thanks for asking. I use VS 2019: 16.11.7 – Suntje Dec 06 '21 at 13:00
-
@Fran I can use the test exploder also but when you have like 300 test cases, it takes time to search in your test exploder. that why i ask if its possible to run a test from the .feature file – Suntje Dec 06 '21 at 13:01
-
The SpecFlow extension for Visual Studio 2010 used to allow you to do precisely this. This was broken in VS 2013, and then removed from the extension. It had something to do with Microsoft changing Test Explorer, making this sort of thing impossible in Visual Studio from a .feature file. A similar question from 2018 which has no accepted answer: [How can I run scenario of single Feature file in specflow](https://stackoverflow.com/q/53120467/3092298). – Greg Burghardt Dec 08 '21 at 16:09
1 Answers
Running a scenario from a feature file is no longer available, nor is it possible with the current Visual Studio API (as of VS 2019).
GitHub issue #1235 (Run & debug scenarios from the feature file context menu VS 2017) of the SpecFlow project described a bug where the context menu item allowing you to run scenarios from a feature was no longer working in Visual Studio 2017. Further down the comment chain, it looks like this was always a finicky feature:
This feature had always problems, because it uses ugly hacks to bring the different test runners to execute the scenarios. The last time I checked it, it always executed all scenarios of the feature file.
Source: https://github.com/SpecFlowOSS/SpecFlow/issues/1235#issuecomment-414230242
Further down yet, another comment describes that some APIs necessary to support this feature were removed from Visual Studio:
For VS2019 we had to remove this feature. The APIs, we were using, are removed with VS2019 (microsoft/vstest#1830).
Source: https://github.com/SpecFlowOSS/SpecFlow/issues/1235#issuecomment-476268630
As a result, it is no longer possible to run a scenario when you have a feature file loaded in the editor panel in Visual Studio.

- 17,900
- 9
- 49
- 92
-
Oke thankyou for your answer Greg. Then we will use the normale way from test explorer. – Suntje Dec 10 '21 at 07:42