6

I cannot get the filter parameter in Open cover working, even if I try a very simple console app with tests. Here is the filter - I am running as adminstrator

This:

"C:\Users\Mojo\AppData\Local\Apps\OpenCover\OpenCover.Console.exe" 
  -output:c:\coverage.xml -register:user 
  -target:"C:\TEMP\sonarqube-5.1\xunitRunner\xunit.console.exe" 
  -targetargs:"ConsoleApp.Tests.dll" 
  -filter:"+[ConsoleApp.*]* -[ConsoleApp.Tests]*"

Yields this:

    1) missing PDBs for the assemblies that match the filter please review the
    output file and refer to the Usage guide (Usage.rtf) about filters.
    2) the profiler may not be registered correctly, please refer to the Usage
    guide and the -register switch.

However, if I run this without the filter, I get coverage results:

"C:\Users\Mojo\AppData\Local\Apps\OpenCover\OpenCover.Console.exe" 
  -output:c:\coverage.xml -register:user 
  -target:"C:\TEMP\sonarqube-5.1\xunitRunner\xunit.console.exe" 
  -targetargs:"ConsoleApp.Tests.dll" 
Visited Classes 8 of 101 (7.92)
Visited Methods 20 of 305 (6.56)
Visited Points 52 of 1099 (4.73)
Visited Branches 27 of 958 (2.82)
==== Alternative Results (includes all methods including those without corresponding source) ====
Alternative Visited Classes 9 of 108 (8.33)
Alternative Visited Methods 28 of 416 (6.73)

My console is executing the statement from the project directory.

Luke Girvin
  • 13,221
  • 9
  • 64
  • 84
KnowHoper
  • 4,352
  • 3
  • 39
  • 54

1 Answers1

7

By default if you supply no filter argument OpenCover will apply some default filters.

If you supply filters then exclusion filters take priority, then inclusion filters with a final exclusion default.

The first part of the filter is the module [] (usually this is the name of the assembly excluding the file extension), that latter part is the namesspace/type filter.

Without knowing all the names of your assemblies/namespaces it is hard to say what your filter(s) should be, however try

-filter:"+[ConsoleApp]* -[ConsoleApp.Tests]*"

or

-filter:"+[*]* -[ConsoleApp.Tests]*"
Shaun Wilde
  • 8,228
  • 4
  • 36
  • 56