Search code examples
c#nunitnunit-consolenunit-3.0

How to use filter with --explore command line option


I have group of tests divided to categories

[TestFixture]
[Category("someCategory")]
public class MyTestClass
{
    [Test, TestCaseSource("TestData")]
    public void MyTest(...)
    {
    }
}

I'm trying to get list of tests filtered by category via nunit3-console using

nunit3-console.exe --explore:results myTests.exe --where:"cat == someCategory"

However, it seems that --where option applies only for running tests and the results file contains list of all my tests, not only tests with category "someCategory".

How can I get a filtered list?


Solution

  • The where filter is not currently applied when exploring tests. There is an issue to enable it for exploring tests. Add your comments along with your use case to help boost the visibility/priority of the issue if you want it changed. Pull requests are also welcome ;)

    As a workaround, you could run your tests with your where clause and add --labels=All to output the tests to the console. The resulting list will need a bit of massaging in Notepad++, but it should give you what you need.