Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make VS ignore code coverage for Test dll

Currently, when I run code coverage analysis the reported coverage is 90%. The thing is that the other 10% is the code for the actual test!

How can i make VS ignore that test code and only take into account the actual code?

like image 264
Leonardo Avatar asked Oct 28 '25 14:10

Leonardo


1 Answers

You can add a runsettings file in your project.

In that file you can mention DLL names which needs to be excluded from code coverage:

<ModulePaths>
  <Include>
    <!-- Include all loaded .dll assemblies (but not .exe assemblies): -->
    <ModulePath>.*\.dll$</ModulePath>
  </Include>
  <Exclude>
    <!-- But exclude some assemblies: -->
    <ModulePath>.*\\Fabrikam\.MyTests1\.dll$</ModulePath>
    <!-- Exclude all file paths that contain "Temp": -->
    <ModulePath>.*Temp.*</ModulePath>
  </Exclude>
</ModulePaths>

This page and This page should give you more details on how to add and how to configure runsettings file for unit tests.

Hope this helps you.

like image 97
Manoj Choudhari Avatar answered Oct 30 '25 05:10

Manoj Choudhari



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!