12
votes

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

1
I'd add xUnit tests also. How to filter those?Csaba Toth

1 Answers

10
votes

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!