Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSTest - Hide some unit tests from build server

Tags:

I have three unit tests that cannot pass when run from the build server—they rely on the login credentials of the user who is running the tests.

Is there any way (attribute???) I can hide these three tests from the build server, and run all the others?

Our build-server expert tells me that generating a vsmdi file that excludes those tests will do the trick, but I'm not sure how to do that.

I know I can just put those three tests into a new project, and have our build-server admin explicitly exclude it, but I'd really love to be able to just use a simple attribute on the offending tests.

like image 249
Adam Rackis Avatar asked May 19 '11 14:05

Adam Rackis


2 Answers

You can tag the tests with a category, and then run tests based on category.

[TestCategory("RequiresLoginCredentials")] public void TestMethod() { ... } 

When you run mstest, you can specify /category:"!RequiresLoginCredentials"

like image 144
David Yaw Avatar answered Oct 07 '22 01:10

David Yaw


There is an IgnoreAttribute. The post also lists the other approaches.

like image 24
pickypg Avatar answered Oct 07 '22 01:10

pickypg