12

In TFS 2012, we have several build definitions - CIs, Deployments and nightly.

Our CI builds run all of the (n)unit tests from our solution, however, we need to get it to ignore certain tests.

This is because we have some long running integration tests, and these only need to be run nightly.

Things I've tried:

  • Using the TestCategoryAttribute (from MSTest) and setting the Test Case Filter property try and exclude 'Integration'.
  • Using the CategoryAttribute (from NUnit) and setting the Test Case Filter property try and exclude 'Integration'.
  • A combination of the above.

The tests that need to be ignored are all in separate assemblies with the word IntegrationTests or Integration.Tests in the name.

Thanks,
Kieron

Kieron
  • 26,748
  • 16
  • 78
  • 122

1 Answers1

10

I've been using a combination of the MSTest TestCategory attribute on my unit tests, and the Test category filter setting for my build process definition in TFS 2012.

According to the Microsoft MSDN article found here you can specify which categories to use by setting the Test category filter to

TestCategory=CategoryName

According to your original post, you'd need to use the following filter:

TestCategory!=Integration

and decorate your tests with this attribute:

[TestCategory("Integration")] 

Do this on all of your unit tests that you want ignored during your build. The test lists have been deprecated in Visual Studio, and it took a while to convert everything to the categories, but in the end it's worth it.

Hope that helps!

Allen Rice
  • 19,068
  • 14
  • 83
  • 115
Jeff Winn
  • 804
  • 8
  • 14
  • They don't explicitly mention it anywhere in documentation, but this syntax works for ANDS TestCategory!=External&TestCategory!=UITest – felickz Sep 27 '13 at 17:18
  • 2
    That's good for MSTests, but how about NUnit tests? And personally I'm interested in xUnit test filtering also, we have all of the three kinds. – Csaba Toth Oct 22 '13 at 22:12
  • 1
    I'll second xUnit...! – Kieron Oct 23 '13 at 12:20
  • 1
    Note that if you are filtering Test categories in your TFS build definitions you leave out the _TestCategory=_ bit and just specify the CategoryName by itself e.g. _!Integration_ – kiwiaddo Mar 26 '15 at 21:36