Unit test by skipping library functions for code coverage

Viewed 199

I am trying to create a unit test in MS Test for a CMS application, wherein I have minority number of function that I wrote in my solution, the majority of the functions came along with CMS framework.

Issue:

When I take the code coverage it shows less than 1 percentage. But this coverage is meaningless.

Question:

How can I find coverage for only the functions that I wrote skipping the library functions that came along with cms framework?

2 Answers

You can configure which assemblies your code coverage should look for.

You need to edit .runsettings file for the Unit tests and add this

<ModulePaths>  
  <Exclude>  
   <ModulePath>Name of the dll goes here</ModulePath>  
   <!-- Add more ModulePath nodes here. -->  
  </Exclude>  
</ModulePaths>  

For more information refer the link https://msdn.microsoft.com/en-IN/library/jj159530.aspx

There is a ExcludeFromCodeCoverage attribute you can use.

You may need to isolate the CMS calls to a class or methods that you can decorate with this Attribute to skip the library functions.

Related