<Filter> element allows you to define filters that are applied to your tests, allowing you to determine which tests to execute. Filters can also be defined in
<Target> elements, in which case the filter only applies to that target. Filters defined outside of a
<Target> element are applied globally. The Test Explorer window in Visual Studio only lists those tests that meet your filter criteria (after rebuilding your project). Note that global filters also apply when running tests by right-clicking on a feature file and selecting Run SpecFlow Scenarios.
Filters can be applied to tests based on tags (including regular expressions), or the scenario or feature name.
Note: Tags and filters are case-sensitive.
The following filter types can be defined:
|@||Tag||Matches a tag exactly, e.g. '@MyTag' only returns those tests with the '@MyTag' tag.|
|tagmatch:||Tag||Matches tags by regular expression, e.g. 'tagmatch:Tag[1-3]' matches tests with the tags 'Tag1', "Tag2' or 'Tag3'.|
|testpath:Feature:||Test||Matches tests by feature name. You can use the
|testpath:Scenario:||Test||Matches tests by scenario name. You can use the
You can combine filters using logical operators. The following operators are supported:
- |: OR
- &: AND (however you need to use
&instead in the profile, as it is an XML file)
- !: NOT
<Filter>@MyTag & @YourTag</Filter> executes all tests with both the
<Filter>tagmatch:!Tag[1-9]</Filter> executes all tests that are not tagged with any of
Filter>@MyTag | tagmatch:tag[1-9]</Filter> executes all tests with either the
@MyTag tag or tags