Ramu Sangabathula
Ramu Sangabathula

Reputation: 31

Open Cover filters how to avoid test assembly files from code coverage

I have gone through the Opencover wiki documentation and tried a lot to figure out what would be the filter criteria for not to include test assembly as part of code coverage. Here is the problem

for eg I have many assemblies starts with sample name like sample.submodule.assembly1.dll, sample.submodule.assembly2.dll, my tests assembly also starts with sample like sample.submodule.tests.dll, here I applied the filter criteria for openCover

1.-filter: "+[sample*]* -[*tests]*" it didn't work, not generating report file.

  1. -filter: "+[sample*]* -[sample.submodule.tests]*" didn't work, not generating report file,

  2. -filter: "+[sample*]* -[*]*tests*" didn't work, not generating report file too,

can somebody please advise what can be the filter criteria here to exclude all the test files from code coverage

Upvotes: 2

Views: 8039

Answers (2)

Gomes
Gomes

Reputation: 3330

if you are talking about writing unit test using visual studio nunit adaptor then you have open cover UI visual studio extension available for all such purpose. it is wonderful.

Step 1) Install open cover from latest relese build https://github.com/opencover/opencover/releases Step 2) Usuall it will install C:\Users\goma1940\AppData\Local\Apps\OpenCover (%localappdata%\Apps\OpenCover) Steo 3) Install VS Extn from gallery https://visualstudiogallery.msdn.microsoft.com/6950a046-8919-4935-8542-c6f37956f688 Step 4) you have open cover test explorer and open cover coverage result pane as below…

Upvotes: 0

Shaun Wilde
Shaun Wilde

Reputation: 8358

First run OpenCover without any filters.

Now you can look at the XML report produced (or you can use ReportGenerator to turn it into HTML) and identify assemblies/modules that you wish to exclude.

now you can apply filters using the filter switch e.g.

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

NOTE: no space between : and first "

or

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

Upvotes: 7

Related Questions