Code coverage for a class library using dotCover
Asked Answered
F

2

14

I have a simple class library that gets tested with MSTest using VS 2010.

I installed the trial version of dotCover 1.2. with no ReSharper installed.

VS only has the menu items "Cover Startup Project" and "Cover Application". They open boxes where I can open all kinds of applications but no class library.

Is it not possible to calculate code coverage for a class library without another application that uses it?

Fan answered 21/4, 2012 at 18:27 Comment(2)
You need something to execute your tests - dotCover works well with ReSharper in that respectGumbotil
I created a Unit Test project to execute the methods in my class library so I could cover them.Hasson
H
6

In my case I have a solution containing a class library, and another solution containing the unit tests.

I wanted to see how much of the class library my unit tests covered. After running Cover Unit Tests from the Solution context menu Dotcover by default shows me the coverage of the methods in the test classes themselves. To see the coverage of the class library you need to unselect Match coverage results with current project structure:

enter image description here

Note that this will only cover class library projects referenced in the tests. If you have a project that doesn't have any tests at all then that project won't show as a symbol in the Coverage Tree.

Thanks to this answer for pointing me in the right direction.

Hasson answered 6/11, 2015 at 2:49 Comment(0)
F
1

They have a command line tool that can be used without ReSharper: dotCover.exe.

Documentation is not as well as you might expect from jetbrains but it works.

http://blogs.jetbrains.com/dotnet/2010/07/running-code-coverage-from-the-console-with-dotcover/

Fan answered 21/4, 2012 at 20:11 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.