Jafin
Jafin

Reputation: 4371

How to Exclude a test from running using VS2012, TFS Build and NUnit

I have the following setup Visual studio 2012 Update 2 NUnit Test Adapter Beta 4 NUnit 2.62

I mark a test with either of the following attributes Category from NUnit or TestCategory from MSTest:

[Category("WebServer")]
public void FooTest() {
 //test
}


[TestCategory("WebServer")]
public void FooTest2() {
 //test
}

In the TFS Build Template, I Set the property

  1. Basic -> 1. Test Source -> Test Case Filter to the value: TestCategory!=WebServer

When the build executes NO TESTS execute. Removing the Filter and all tests run again.

The output from the build log is

No test is available in C:\Builds\2\Proj\Build\bin\Debug\Tests.Integration.dll C:\Builds\2\Proj\Build\bin\Debug\Tests.Unit.dll C:\Builds\2\Proj\Build\bin\Debug\Tests.Web.dll C:\Builds\2\Proj\Build\bin\Debug\TestStack.BDDfy.dll. Make sure that installed test discoverers & executors, platform & framework version settings are appropriate and try again.

Any clues how I can get a test to be excluded base on Category name? I can easily verify the attribute works if I use the NUnit console runner.

Upvotes: 4

Views: 4609

Answers (3)

emp
emp

Reputation: 5065

When using NUnit Test Adapter v1.1+, test Categories can be used on TFSBuild. You just need to install the package with your Test Project, and configure test case filter on your build definition.

Upvotes: 3

Bigwave
Bigwave

Reputation: 2206

Answering an old question as this was one of the first results Google returned.

From here it would seem that this was a bug that has been fixed in version 1.1, which unfortunately (as of 22 Jan 2014) has not yet been released to nuget

Upvotes: 1

David Meredith
David Meredith

Reputation: 446

From here it would appear that you cannot use the TestCategory filters on NUnit tests, only on MSTest tests.

As a note, it would also appear that you are changing the property on the TFS Build Definition, not the Build Template. This is what I would expect, as changing the build definition would be the wrong place to change this.

Upvotes: 2

Related Questions