How can I run scenario of single Feature file in specflow

2.5k Views Asked by At

I want to implement TestRunner into my project to execute the test feature wise or in the given order but couldn't find any proper document or video how to integrate TestRunner in the project, as I am new in specflow and automation so I am not getting the idea. If anyone has implemented TestRunner then, please suggest me how can I implement.

I am trying to run my Feature file using right click on Feature file and click on Run as SpecFlow Scenarios but test execution doesn't start do I need to add an extra library to execute feature file using Run as SpecFlow Scenarios.

3

There are 3 best solutions below

2
On

I don't know why but 'Run SpecFlow Scenarios" button from context menu doesn't work indeed.

To be able to run your tests you need to install an adapter for your test framework.

If you use MStest then install MSTest.TestAdapter

If you use Nunit then install NUnit3TestAdapter

When you do you'll see the tests in your tests explorer: enter image description here

1
On

Denis Koreyba provided what you are probably looking for.

Another way could be to run the test from the command line.

These two topics on StackOverflow provide information on how to do this, depending on your test framework:

Console Application to launch Specflow features by code not using ncode runner

How do you run SpecFlow scenarios from the command line using MSTest?

0
On

You can change the test explorer view to "Group by namespace" then you will see all the features and you can run the scenarios inside the feature. Refer below image

enter image description here