How can I force inclusion of untested assemblies to Code Coverage?
Asked Answered
G

0

8

I'm trying to make Visual Studio's Code Coverage tool useful. I'm working on a legacy project and in order to refactor all this code I add unit tests. The problem is, when I measure code coverage I only see three dll assemblies that have tested methods.

Some of you might say that "if it ain't there, it means it's not tested", and basically you are right, but I would like to have this mechanism help me avoid making mistakes. I want to know that the untested classes and methods are there so I know the ratio between covered/not covered.

This is the include/exclude section of my custom .runsettings file.

<ModulePaths>
    <Include>
        <ModulePath>.*Some\.Library\.OfMine\.dll$</ModulePath>
        <ModulePath>.*\.dll$</ModulePath>
    </Include>
    <Exclude>
        <ModulePath>.*my\.tests\.dll$</ModulePath>
        <ModulePath>.*xunit\.core\.dll$</ModulePath>
        <ModulePath>.*fluentassertions\.dll$</ModulePath>
        <ModulePath>.*fluentassertions\.core\.dll$</ModulePath>
    </Exclude>
</ModulePaths>

I don't know why, but code coverage actually lists also FluentAssertions, XUnit and My.Tests.dll (which is storing tests), so I excluded them. That part actually worked. This link helped me with it. But when I added Some.Library.OfMine.dll it doesn't show in code coverage results.

To help point to it I added this section:

<SymbolSearchPaths>              
    <Path>E:\The\Absolute\Path\To\The\Test\Project\bin\Debug</Path>
</SymbolSearchPaths>

And added a reference in the test project to Some.Library.OfMine.dll. I'm sure the dll and pdb are there after build finishes it's job.

But I still can't see Some.Library.OfMine.dll among covered/not covered libraries in code coverage results.

Is it actually possible to do what I'm trying to do? If so, how to achieve that?

Greaser answered 17/2, 2016 at 13:9 Comment(2)
Did you get this working or found a solution to this?Teasel
Not yet, unfortunately...Greaser

© 2022 - 2024 — McMap. All rights reserved.