Sets the filter set to apply, which consists of a sequence of one or more inclusion or exclusion filter rules prefixed using 'include' (optional) or 'exclude'.

Namespace:  Gallio.MSBuildTasks
Assembly:  Gallio.MSBuildTasks (in Gallio.MSBuildTasks.dll) Version: 3.3.0.0 (3.3.459.0)

Syntax

C#
public string Filter { private get; set; }
Visual Basic (Declaration)
Public Property Filter As String

Remarks

A filter rule consists of zero or more filter expressions that may be combined using 'and', 'or', and 'not' and grouped with parentheses. A filter expression consists of a filter key followed by one or more comma-delimited matching values in the form 'key: value, "quoted value", /regular expression/'.

The filter grammar is defined as follows:

CopyC#
INCLUDE          ::= "include"              # Not case-sensitive
EXCLUDE          ::= "exclude"              # Not case-sensitive

OR               ::= "or"                   # Not case-sensitive
AND              ::= "and"                  # Not case-sensitive
NOT              ::= "not"                  # Not case-sensitive

<unquotedWord>   ::= [^:,*()/\"']+

<quotedWord>     ::= '"' .* '"'             # String delimited by double quotation marks
                 | "'" .* "'"               # String delimited by single quotation marks

<word>           ::= <unquotedWord>
                 | <quotedWord>

<regexWord>      ::= "/" .* "/"             # Regular expression
                 | "/" .* "/i"              # Case-insensitive regular expression

<key>            ::= <word>

<value>          ::= <word>                 # Value specified by exact string
                 | <regexWord>              # Value specified by regular expression

<matchSequence>  ::= <value> (',' <value>)* # One or more comma-separated values

<filterExpr>     ::= "*"                    # "Any"
                 | <key> ":" matchSeq>
                 | <filterExpr> OR filterExpr>   # Combine filter expressions with OR
                 | <filterExpr> AND filterExpr>  # Combine filter expressions with AND
                 | NOT <filterExpr>         # Negate filter expression
                 | "(" <filterExpr> ")"     # Grouping filter expression

<filterRule>     ::= <filterExpr>           # Inclusion rule (default case)
                 | INCLUDE <filterExpr>     # Inclusion rule
                 | EXCLUDE <filterExpr>     # Exclusion rule

<filterSet>      ::= <filterRule>           # Filter set consists of at least one filter rule.
                 | <filterRule> <filterSet> # But may be a sequence of rules.

  • By default this property takes the value "*", which means the "Any" filter will be applied.
  • The operator precedence is, from highest to lowest: NOT, AND, and OR. All these operators are left-associative.
  • The commas used to separate the values are interpreted as OR operators, so "Type:Fixture1,Fixture2" is equivalent to "Type:Fixture1 or Type:Fixture2".
  • White-space is ignored outside quoted strings, so "Type:Fixture1|Type:Fixture2" is equivalent to "Type : Fixture1 | Type : Fixture2".
  • Commas, colons, slashes, backslashes and quotation marks can be escaped with a backslash. For example, \' will be interpreted as '. Using a single backslash in front of any other character is invalid.
  • Currently the following filter keys are recognized:
    • Id: Filter by id.
    • Name: Filter by name.
    • Assembly: Filter by assembly name.
    • Namespace: Filter by namespace name.
    • Type: Filter by type name, including inherited types.
    • ExactType: Filter by type name, excluding inherited types.
    • Member: Filter by member name.
    • *: All other names are assumed to correspond to metadata keys. See MetadataKeys for standard metadata keys. Common keys are: AuthorName, Category, Description, Importance, TestsOn.

Examples

Assuming the following fixtures have been defined:

CopyC#
[TestFixture]
[Category("UnitTest")]
[Author("AlbertEinstein")]
public class Fixture1
{
  [Test]
  public void Test1()
  {
  }
  [Test]
  public void Test2()
  {
  }
}

[TestFixture]
[Category("IntegrationTest")]
public class Fixture2
{
  [Test]
  public void Test1()
  {
  }
  [Test]
  public void Test2()
  {
  }
}

The following filters could be applied:

  • Type: Fixture1 All the tests within Fixture1 will be run.
  • Member: Test1 Only Fixture1.Test1 and Fixture2.Test1 will be run.
  • Type: Fixture1, Fixture2 All the tests within Fixture1 or Fixture2 will be run.
  • Type:Fixture1 or Type:Fixture2 All the tests within Fixture1 or Fixture2 will be run.
  • Type:Fixture1, Fixture2 and Member:Test2 Only Fixture1.Test2 and Fixture2.Test2 will be run.
  • Type:/Fixture*/ and Member:Test2 Only Fixture1.Test2 and Fixture2.Test2 will be run.
  • AuthorName:AlbertEinstein All the tests within Fixture1 will be run because its author attribute is set to "AlbertEinstein".
  • Category: IntegrationTest All the tests within Fixture2 will be run because its category attribute is set to "IntegrationTest".
  • ("Type": 'Fixture1' and "Member":/Test*/) or (Type : Fixture2 and Member: /Test*/) All the tests will be run. This example also shows that you can enclose key and values with quotation marks, and group expressions with parentheses.
  • exclude AuthorName: AlbertEinstein All the tests within Fixture2 will be run because its author attribute is not set to "AlbertEinstein".
  • exclude Type: Fixture2 include Member: Test2 Only Fixture1.Test2 will be run because Fixture2 was excluded from consideration before the inclusion rule was applied.

See Also