Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio Code Coverage Not Showing All Assemblies

I have 20 projects in my .SLN file. I am running my unit tests through the Test Explorer and generating the code coverage. Only eight of the projects show up in the coverage (see screenshots). I am using a runsettings file in which I have commented out the contents of all of the <exclude> tags, like so:

        <PublicKeyTokens>
          <!-- Exclude Visual Studio extensions: -->
          <Exclude>
            <!--
            <PublicKeyToken>^B77A5C561934E089$</PublicKeyToken>
            <PublicKeyToken>^B03F5F7F11D50A3A$</PublicKeyToken>
            <PublicKeyToken>^31BF3856AD364E35$</PublicKeyToken>
            <PublicKeyToken>^89845DCD8080CC91$</PublicKeyToken>
            <PublicKeyToken>^71E9BCE111E9429C$</PublicKeyToken>
            <PublicKeyToken>^8F50407C4E9E73B6$</PublicKeyToken>
            <PublicKeyToken>^E361AF139669C375$</PublicKeyToken>
            -->
          </Exclude>
        </PublicKeyTokens>

I cannot figure out why the other 12 projects are not shown in the coverage results. Any ideas?

Solution Projects:

Visual Studio Project Listing

Code Coverage Results:

enter image description here

like image 358
michaelkoss Avatar asked Feb 20 '13 21:02

michaelkoss


People also ask

How do I enable code coverage in Visual Studio?

Starting in Visual Studio 2022 Update 2, you can enable faster code coverage test results by selecting Tools > Options > Environment > Preview Features, then selecting Code coverage experience improvements, and then restarting Visual Studio.

How do you show code coverage?

To calculate the code coverage percentage, simply use the following formula: Code Coverage Percentage = (Number of lines of code executed by a testing algorithm/Total number of lines of code in a system component) * 100.


1 Answers

Adding <DebugType>Full</DebugType> to target .csproj file, worked for me

<PropertyGroup>
     <TargetFramework>netstandard2.0</TargetFramework>
     <DebugType>Full</DebugType>
</PropertyGroup>
like image 142
Victor SDK Avatar answered Oct 05 '22 05:10

Victor SDK