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

Behind the scene specflow tests are just regular mstest unit tests. So you should be able to run them the same way using something like:

To run a specific scenario:

mstest /testcontainer:tests.dll /test:GivenMyScenarioWhenIDoSomeStuff

To run a several specific scenario you can use the /test flag multiple times:

mstest /testcontainer:tests.dll /test:GivenMyScenarioWhenIDoSomeStuff /test:GivenMyScenarioWhenIDoSomemthingElse

To run a feature

mstest /testcontainer:tests.dll /test:MyFeatureName

If you add tags on your scenarios using @MyTag for example, you could also use the option

/category:MyTag to filter down the scenarios to run.

Please have a look to the generated code behind of your feature files to get a clue of how things actually work, if you are familliar with mstest it should be pretty straightforward.

Leave a Comment