visual studio – Using the Filter Parameter in OpenCover to Measure Coverage of a Single Function in VB


I want to focus on a specific function and have been trying to use the -filter parameter in OpenCover. My code contains functions like add, sub, mul, and div, and I’m looking to configure OpenCover to display coverage only for certain functions, such as ‘add’ or ‘sub,’ using the filter option

These are the method that I have tried for filters

filter:" -[*]* +[TestCoverage1.Calculator]Add"  -output:"
filter:"+[YourNamespace]YourClass::YourMethod -[*]*"
filter:"[*]* -[A*]Name.*"
filter:"+[YourAssemblyName]*YourNamespace.YourClass.YourMethod*"
filter="+[*]*Add +[*]*Subtract -[*]*Multiply -[*]*Divide"
filter:"[testcoverage1]*[*]Testcoverage1.Calculator.add"
filter:+"[TestCoverage1]*-[TestCoverage1]* 
     [*]TestCoverage1.Calculator.add"
filter:"+[TestCoverage1]* -[TestCoverage1]* 
      [*]TestCoverage1.Calculator.add"
filter:"-[TestCoverage1]* -[TestCoverage1]* + 
       [*]TestCoverage1.Calculator.add"
filter:"+[TestCoverage1]*TestCoverage1.Calculator.Add*"

In certain filter cases, the following message is displayed despite everything being correctly configured

No results, this could be for a number of reasons. The most common reasons are:
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.
3) your assemblies under test were not be loaded, refer to the output xml
and check your filters/code.
4) you are targetting .net core and your assemblies under test were not
instrumented, try using the -oldstyle switch.
5) you are targetting 4.8 or .net core and your assemblies under test were
not instrumented, try using the -register:path32 or -register:path64 switch.

Can you provide guidance on how to properly use the -filter parameter to include a particular function?

Leave a Reply

Your email address will not be published. Required fields are marked *