I want to be able to run each specflow feature from vstest.console.exe command line instead of running all the tests in that project. I realize there is a command line argument for filtering by category but its not obvious to me how to define categories for specflow tests. Is there a way to do this or is there any other way to accomplish grouping specflow tests to be run via command line with vstest.console?
-
For anyone interested, the following worked for me. I went into my feature file and add at the very top *@BlahBlahFeature* Then I ran vstest.console.exe with the command line arguemnt: **/TestCaseFilter:FullyQualifiedName~"BlahBlahFeature"** Be sure an do a **~** instead of **=** because **=** does not seem to work for me; **~** stands for contains. – user123959 Jul 18 '14 at 16:16
1 Answers
You want Tags. SpecFlow becomes much easier to understand once you realize SpecFlow implements the Gherkin Language.
From the Tags documentation:
Tags are a great way to organise your features and scenarios. ... A Scenario or feature can have as many tags as you like. Just separate them with spaces ... Any tag that exists on a Feature will be inherited by Scenario, Scenario Outline or Examples.
A quick example:
@posts
Feature: Blog Posts
@comments
Scenario: Adding a comment
...
@comments
Scenario: Deleting a comment
...
The @foo
syntax just above the declaration for a Scenario creates categories you can run using MS Test.
After that you can use the "Test View" pane in Visual Studio to filter all of your tests by Category, or run them from the Visual Studio command line:
mstest /testcontainer:Blog.Tests.dll /category:comments
I actually had a similar (but not duplicate) question a while back: How do you run SpecFlow scenarios from the command line using MSTest?. It might be a good read.

- 1
- 1

- 17,900
- 9
- 49
- 92