Search code examples
opencover

OpenCover how to exclude tests with certain Category


I'm trying to figure out how to exclude certain tests that are marked by nunit category attribute and can't find it in documentation.

For instance: this test I want to be excluded:

    [Test]
    [Category("PerfomanceTests")]
    [Timeout(3000)]
    public void Some test()
    {...}

Solution

  • You won't find how to exclude tests by category in OpenCover documentation as it is not a test runner.

    OpenCover executes the program that runs your tests e.g. nunit-console.exe as such you need to look at nunit documentation and the /include and /exclude switches and pass them to OpenCover via the -targetargs: switch along with other arguments that you may use.

    -targetargs:"tests.dll /exclude:PerfomanceTests"