Reputation: 451
[TestFixture(Category = "P1")]
public class TestClass
{
[Test(Category = "P2")]
public void Method()
{
//test
}
}
In the above code snippet, what will be considered the TestCategory
of Method
: "P1" or "P2" or both?
I want to use the category to filter out the tests.
Upvotes: 1
Views: 1276
Reputation: 13726
In a technical sense, P1 is the category of TestClass and P2 is the category of Method. That's clear.
As Chris points out, categories are not inherited. However, that's not important to you for most purposes of filtering.
Either of the following options on the console runner command line will run Method:
--where "cat==P1"
--where "cat==P2"
Either of the following will exclude Method
--where "cat!=P1"
--where "cat!=P2"
This command would run all the tests in TestClass except for Method:
--where "cat==P1&&cat!=P2"
IOW, it acts like the category is inherited, although it isn't.
Upvotes: 2
Reputation: 6042
Currently, your test method will only be category P2.
Categories are currently not inherited. There are open GitHub issues to change that behaviour here: https://github.com/nunit/nunit/issues/796 and here: https://github.com/nunit/nunit/issues/1396
Upvotes: 1