How to avoid running tests in mstest without using the ignore attribute?

We have several unit tests that we use when integrating with external services. These services can be unstable, and they are out of our control, which makes it necessary to remove them from our daily build.

We have had integration tests in a separate assembly since regular unit tests are performed as part of our closed test.

However, there are a number of integration tests that we want to run as part of our daily build, and therefore we cannot completely remove builds from the daily build.

I tried to remove the [TestClass] attribute, and it works fine in VS2012. But when we check and you have TFS (2010) to create and run tests, I got the following error.

[errormessage] = UTA004: Illegal use of the attribute on Test.TestMethod. TestMethodAttribute can only be defined inside a class marked with the TestClass attribute.

Anyone have an idea how to completely remove test runs? [Ignore] will not, then my test runs will be cluttered with warnings about ignored tests.

+4
source share
1 answer

Why not use TestCategoryAttribute to decorate your integration tests.

For example, run the following tests:

 [TestClass] public class Tests { [TestMethod] public void AtomicTest { Assert.IsTrue(true); } [TestMethod, TestCategory("Integration")] public void IntegrationTest { Assert.IsFalse(false); } } 

And then configure your TFS builds only to run the ones you are interested in:

+4
source

All Articles