Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TFS visual studio test "Test Filter criteria" and xunit Traits

Tags:

tfs

xunit

I'm trying to filter out some unit test marked with the xunit trait category. On my build server I don't want unit test to run with category integration

 [Trait("Category", "Integration")]

When I don't use the 'Test Filter criteria' in TFS VS test step, the unit test all get executed. But when I apply the desired filter

Category!=Integration

It doesn't run any tests at all. I've tried all variations but no success. I also tried using the 2.* version of the test task.

like image 747
Casper Broeren Avatar asked Oct 28 '25 12:10

Casper Broeren


1 Answers

Instead of using [Trait("Category", "Integration")], use [Trait("TestCategory", "Integration")]. XUnit doesn't care what you put in for these key-value pairs, but the TFS Test runner task DOES. The Test Filter Criteria box only works with a prescribed set of attributes. I have this working for our builds. Ran into the same problem you are describing. After analyzing the build output, (and getting ALL test projects switched to XUnit - that is also a key... don't have a mix of MSTest and XUnit).

like image 88
JeremyH Avatar answered Oct 31 '25 12:10

JeremyH