FortuneN / FineCodeCoverage

Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too)
https://marketplace.visualstudio.com/items?itemName=FortuneNgwenya.FineCodeCoverage
Other
518 stars 39 forks source link

NUnit Code Coverage #435

Closed SteveAndrews closed 1 month ago

SteveAndrews commented 1 month ago

Installed product versions

Description

NUnit code coverage isn't being reported. I've looked through the Issues log, but haven't found what I might be doing wrong. I'm also not sure where to find the log files?

Steps to recreate

Unsure

Current behavior

When I run my unit tests, the MSTest test project is reflected in the results, but the NUnit project is not.

Expected behavior

NUnit test project results should be included in the overall results.

image

tonyhallett commented 1 month ago

What FCC options are you using ?

SteveAndrews commented 1 month ago

FCC Options?

tonyhallett commented 1 month ago

Fine Code Coverage. Please ensure you have read the readme of this repository. You need to provide some context so I can determine what your issue is. FCC is able to provide coverage for solutions with different test frameworks. What does FCC log ? Is ms code coverage being used ?

SteveAndrews commented 1 month ago

I haven't set any options or project settings.

1) Clean install 2) Show FCC tool window 3) Run tests

In the output log (Output Window), I don't see the ProjectName.NUnitIntegrationTests project listed at all (though there is a fine-code-coverage folder in that project's Debug directory):

Fine Code Coverage 7/10/2024 13:14:45: Ms code coverage
Fine Code Coverage 7/10/2024 13:14:55: ReportGenerator Run Arguments [reporttype:Cobertura] 
"-targetdir:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output"
"-reports:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\10014e2e-8094-4353-aa7f-c09977a933bc\steve_DESKTOP-NAIOOIK_2024-07-10.13_14_49.cobertura.xml"
"-reporttypes:Cobertura"
Fine Code Coverage 7/10/2024 13:14:56: ReportGenerator Run [reporttype:Cobertura]
2024-07-10T13:14:55: Arguments
2024-07-10T13:14:55:  -targetdir:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output
2024-07-10T13:14:55:  -reports:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\10014e2e-8094-4353-aa7f-c09977a933bc\steve_DESKTOP-NAIOOIK_2024-07-10.13_14_49.cobertura.xml
2024-07-10T13:14:55:  -reporttypes:Cobertura
2024-07-10T13:14:55: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Windows.Forms.Analyzers.CSharp\System.Windows.Forms.Generators.ApplicationConfigurationGenerator\ApplicationConfiguration.g.cs' does not exist (any more).
2024-07-10T13:14:55: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\Microsoft.Interop.LibraryImportGenerator\Microsoft.Interop.LibraryImportGenerator\LibraryImports.g.cs' does not exist (any more).
2024-07-10T13:14:55: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:55: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:55: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:55: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:55: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:56: Writing report file 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\Cobertura.xml'
2024-07-10T13:14:56: Report generation took 0.4 seconds
Fine Code Coverage 7/10/2024 13:14:56: ReportGenerator Run Arguments [reporttype:HtmlInline_AzurePipelines] 
"-targetdir:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output"
"-reports:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\Cobertura.xml"
"-plugins:c:\users\steve\appdata\local\microsoft\visualstudio\17.0_740f139a\extensions\y3vk1voq.cga\ReportGeneratorPlugins.dll"
"-reporttypes:FccLight"
"riskHotspotsAnalysisThresholds:metricThresholdForCyclomaticComplexity=30"
"riskHotspotsAnalysisThresholds:metricThresholdForCrapScore=15"
"riskHotspotsAnalysisThresholds:metricThresholdForNPathComplexity=200"
Fine Code Coverage 7/10/2024 13:14:56: ReportGenerator Run [reporttype:HtmlInline_AzurePipelines]
2024-07-10T13:14:56: Arguments
2024-07-10T13:14:56:  -targetdir:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output
2024-07-10T13:14:56:  -reports:C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\Cobertura.xml
2024-07-10T13:14:56:  -plugins:c:\users\steve\appdata\local\microsoft\visualstudio\17.0_740f139a\extensions\y3vk1voq.cga\ReportGeneratorPlugins.dll
2024-07-10T13:14:56:  -reporttypes:FccLight
2024-07-10T13:14:56:  riskHotspotsAnalysisThresholds:metricThresholdForCyclomaticComplexity=30
2024-07-10T13:14:56:  riskHotspotsAnalysisThresholds:metricThresholdForCrapScore=15
2024-07-10T13:14:56:  riskHotspotsAnalysisThresholds:metricThresholdForNPathComplexity=200
2024-07-10T13:14:56: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Windows.Forms.Analyzers.CSharp\System.Windows.Forms.Generators.ApplicationConfigurationGenerator\ApplicationConfiguration.g.cs' does not exist (any more).
2024-07-10T13:14:56: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\Microsoft.Interop.LibraryImportGenerator\Microsoft.Interop.LibraryImportGenerator\LibraryImports.g.cs' does not exist (any more).
2024-07-10T13:14:56: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:56: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:56: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:56: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:56: File 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\ProjectName\obj\Debug\net8.0-windows\System.Text.RegularExpressions.Generator\System.Text.RegularExpressions.Generator.RegexGenerator\RegexGenerator.g.cs' does not exist (any more).
2024-07-10T13:14:56: Writing report file 'C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\Tests\ProjectName.Tests\bin\Debug\net8.0-windows\fine-code-coverage\coverage-tool-output\index.html'
2024-07-10T13:14:56: Report generation took 0.4 seconds
Fine Code Coverage 7/10/2024 13:14:56: Processing cobertura
Fine Code Coverage 7/10/2024 13:14:56: Processing report
Fine Code Coverage 7/10/2024 13:14:57: ================================== DONE ==================================

Here's the NUnit test project csproj if that helps:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>net8.0-windows</TargetFramework>
        <ImplicitUsings>enable</ImplicitUsings>
        <Nullable>enable</Nullable>

        <IsPackable>false</IsPackable>
        <IsTestProject>true</IsTestProject>
        <SignAssembly>True</SignAssembly>
        <AssemblyOriginatorKeyFile>C:\Users\steve\Documents\Documents\Dev\ProjectName\ProjectName\sgKey.snk</AssemblyOriginatorKeyFile>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="coverlet.collector" Version="6.0.2">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
        <PackageReference Include="Moq" Version="4.20.70" />
        <PackageReference Include="NUnit" Version="4.1.0" />
        <PackageReference Include="NUnit.Analyzers" Version="4.2.0">
            <PrivateAssets>all</PrivateAssets>
            <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
        </PackageReference>
        <PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
        <PackageReference Include="Unity" Version="5.11.10" />
    </ItemGroup>

    <ItemGroup>
        <ProjectReference Include="..\..\ProjectName\ProjectName.csproj" />
    </ItemGroup>

    <ItemGroup>
        <Using Include="NUnit.Framework" />
    </ItemGroup>

</Project>
tonyhallett commented 1 month ago

I don't know what the default FCC options are from memory. Ensure that the option to include test projects is set as well as include referenced projects.

tonyhallett commented 1 month ago

@SteveAndrews did this resolve your issue ?