Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Don't Run Unit Tests from Certain Assemblies in TFS 2012 Build Definition

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

like image 867
Kieron Avatar asked Jul 19 '12 09:07

Kieron


1 Answers

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!

like image 52
Jeff Winn Avatar answered Sep 23 '22 12:09

Jeff Winn