Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

resharper is not ignoring tests marked with Category Attribute in XUnit

having:

[Category("Contract")]
public class ProgramClientShould
{
}

or:

[Trait("Contract", null)]
public class ProgramClientShould
{
}

and Resharper -> Options -> Tools -> Unit Testing: "Skip tests from categories" with value "Contract"

Still, tests in ProgramClientShould are executed. What's wrong?

like image 607
Pato Loco Avatar asked Jun 12 '15 15:06

Pato Loco


People also ask

How do I ignore test cases in xUnit?

When using the default testing framework in . NET your tests will be decorated with a testmethod attribute and you can just place the ignore attribute above them. When you have the ignore attribute above a testmethod the test will be skipped. Now when you run your tests you will see that this test has been skipped.

Which xUnit attribute allows you to arbitrarily categorize tests?

Categorizing Using xUnit Trait The standard way of categorizing tests in xUnit is by using Trait.

Which attribute is used to mark a method as test method in xUnit?

This method is decorated with the Fact attribute, which tells xUnit that this is a test.

Does xUnit run tests in parallel?

Running unit tests in parallel is a new feature in xUnit.net version 2. There are two essential motivations that drove us to not only enable parallelization, but also for it to be a feature that's enabled by default: As unit testing has become more prevalent, so too have the number of unit tests.


1 Answers

xunit doesn't have a Category attribute, so the resharper runner won't recognise that. As for the trait attribute, you need to provide a value, then filter for something in the format key[value]. E.g. if you want to use [Trait("Owner", "Matt")], you would filter for a category of Owner[Matt].

The trait key Category is treated differently, and just the value is used, so [Trait("Category", "integration")] would use integration as the category filter in the resharper options.

like image 114
citizenmatt Avatar answered Oct 16 '22 15:10

citizenmatt