5

In Visual Studio Team Services (VSTS) when defining a build I can filter specific tests to be included or excluded when running tests.

Question: How do I filter complete test classes from execution? The example in the screenshot demonstrates how I filter tests based on their category.

Sample test class which I'd like to exclude:

[TestClass] // .NET 4.5
public class SampleTests
{
    [TestMethod, TestCategory("Integration")]
    public void Test1() {}

    [TestMethod, TestCategory("Integration")]
    public void Test2() {}

    ...
}

Current configuration to exclude my integration tests:

test category filtering

Trial: The filter criteria ClassName!=SampleTests doesn't work. It seems to be reserved for store apps only. Fairly good documentation here: MSDN Blog by Vikram Agrawal.

Reason for asking: I've got test classes initialize lots of data first before running any test and run a clean-up job at the end. When all my tests are excluded via the aforesaid filter the class initialization and clean-up still happen which consumes a lot of time and resources. I like to optimize this.

Quality Catalyst
  • 5,693
  • 7
  • 34
  • 57
  • This is a great question. Who develops "store apps" anyways, and why does that have anything to do with TFS testing :( very strange. Anyways did you ever find a solution or workaround to this issue? I have a very similar problem. – David Rogers Nov 21 '16 at 16:05
  • Hi @DavidRogers, still having this issue to solve. Peter's solution wasn't bringing me any further yet unfortunately. Currently I am just tolerating the long test runs. – Quality Catalyst Nov 23 '16 at 02:57

1 Answers1

0

You can do this with:

FullyQualifiedName!=namespace.SampleTests
Peter
  • 26,307
  • 7
  • 58
  • 80
  • Thanks @Peter! The ~ operator is for inclusions, but I need a solution for exclusions. How would you use the ~ operator to exclude a class/namespace? Or are you suggesting `FullyQualifiedName!=SampleTests`? – Quality Catalyst Apr 04 '16 at 19:44
  • 1
    Then you probably can use FullyQualifiedName!=namespace.SampleTests – Peter Apr 04 '16 at 19:45
  • Ran multiple trials including a fully qualified namespace and class name as defined in the assembly without success. – Quality Catalyst Apr 04 '16 at 20:18
  • 1
    I suspect that the FQN contains the assembly name as well, have you tried `!(FullyQualifiedName~NameSpace.Class)`? It tends to be easier to do this at the assembly name level and add `;-:SampleTestsAssembly.dll;` to the *Test Assembly* option of the Run tests task. – jessehouwing Sep 29 '16 at 10:15