3

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?

SmartestVEGA
  • 8,415
  • 26
  • 86
  • 139

2 Answers2

3

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

Ipsit Gaur
  • 2,872
  • 1
  • 23
  • 38
2

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.

Jeremy Thompson
  • 61,933
  • 36
  • 195
  • 321
  • I am not sure, I can alter the framework code, I need to keep the framework code as it is and get the coverage excluding the framework code. – SmartestVEGA Sep 25 '17 at 07:01
  • 1
    The idea was a middle layer that excluded the CMS layer. @Ipsit answer looks better for what you want. – Jeremy Thompson Sep 25 '17 at 07:03