Why rider Code coverage and visual studio enterprise doesnot match?

In Jetbrains rider and visual studio when I write unit tests and try to cover they both give different results. why??. is the rider and visual studio  different code coverage technology.

1 comment

Hi Sandip Chaudhary,

Let's clarify that Rider uses dotCover as a plugin for the code coverage feature. So, the question turns into "How dotCover and Visual Studio code coverage differ?"

The main cause of the difference between dotCover and Visual Studio coverage results is that dotCover in Rider includes in the coverage report all assemblies from the opened solution and only them. Visual Studio coverage includes in the report all assemblies that have been loaded during the tests run and doesn't include not loaded assemblies, regardless of the solution structure.

Thus dotCover report contains all your assemblies and doesn't contain anything else. Visual Studio report doesn't contain some of your assemblies but contains e.g. xunit*, moq and other third-party assemblies. The third-party assemblies are mostly uncovered which makes Azure DevOps coverage percent smaller.

The second point is that dotCover and Visual Studio use different coverage metrics: statement coverage in dotCover vs lines/blocks coverage in Visual Studio. One line/block can contain several statements. That's why coverage numbers can be different even for the same assemblies and tests. 

Hope I have explained it well :)

If you would like a more accurate answer, please provide a particular example. Have a nice day!


Please sign in to leave a comment.