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
522 stars 40 forks source link

MS Code Coverage does not work if .runsettings file already exists #321

Closed cschulteksa closed 1 year ago

cschulteksa commented 1 year ago

Installed product versions

Description

Code coverage results are blank/empty when .runsettings file exists. If I delete the .runsettings file then it works. However, this is not a reasonable solution, I need to keep the .runsettings file to cooperate with other developers who are using different testing tools.

Steps to recreate

  1. Create an existing .runsettings file, for example:

    <!-- File name extension must be .runsettings -->
    <RunSettings>
    <DataCollectionRunSettings>
        <DataCollectors>
            <DataCollector friendlyName="Code Coverage" uri="datacollector://Microsoft/CodeCoverage/2.0" assemblyQualifiedName="Microsoft.VisualStudio.Coverage.DynamicCoverageDataCollector, Microsoft.VisualStudio.TraceCollector, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
                <Configuration>
                    <CodeCoverage>
                        <ModulePaths>
                            <Exclude>
                                <ModulePath>.*UnitTests.dll</ModulePath>
                                <ModulePath>.*IntegrationTests.dll</ModulePath>
                            </Exclude>
                        </ModulePaths>
    
                        <!-- Match attributes on any code element: -->
                        <Attributes>
                            <Exclude>
                                <!-- Don't forget "Attribute" at the end of the name -->
                                <Attribute>^System\.Diagnostics\.DebuggerHiddenAttribute$</Attribute>
                                <Attribute>^System\.Diagnostics\.DebuggerNonUserCodeAttribute$</Attribute>
                                <Attribute>^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$</Attribute>
                                <Attribute>^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$</Attribute>
                            </Exclude>
                        </Attributes>
    
                    </CodeCoverage>
                </Configuration>
            </DataCollector>
        </DataCollectors>
    </DataCollectionRunSettings>
    </RunSettings>
  2. Set RunMsCodeCoverage to 'Yes' in settings

  3. Create unit tests

  4. Run unit tests

  5. Code coverage is blank

Current behavior

No code coverage results are produced. Coverage Log tab says "No cobertura files for ms code coverage"

Expected behavior

Code coverage results should be produced.

Side Notes

CoenraadS commented 1 year ago

I have the same issue. I see this in the output:

Output

Failed to configure settings for runsettings plugin 'Fine Code Coverage MsCodeCoverageRunSettingsService' as it threw following exception:
'Operation is not valid due to the current position of the navigator.'
Please contact the plugin author.

I have RunMsCodeCoverage to set Yes. If I set it to No, the old way still works.

CodeCoverage.runsettings ``` .*\.dll$ .*\.exe$ TrModuleIdea.Test.* ^System\.Diagnostics\.DebuggerHiddenAttribute$ ^System\.Diagnostics\.DebuggerNonUserCodeAttribute$ ^System\.CodeDom\.Compiler\.GeneratedCodeAttribute$ ^System\.Diagnostics\.CodeAnalysis\.ExcludeFromCodeCoverageAttribute$ .*microsoft.* True True True False True True True ```
System Info ``` Microsoft Visual Studio Professional 2022 Version 17.4.4 VisualStudio.17.Release/17.4.4+33213.308 Microsoft .NET Framework Version 4.8.04084 Installed Version: Professional ASP.NET and Web Tools 17.4.326.54890 ASP.NET and Web Tools Azure App Service Tools v3.0.0 17.4.326.54890 Azure App Service Tools v3.0.0 Azure Functions and Web Jobs Tools 17.4.326.54890 Azure Functions and Web Jobs Tools C# Tools 4.4.0-6.22608.27+af1e46ad38d900023f8b1a2839484e471ece1502 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools. Fine Code Coverage fcc-f339fe606-9d51-4fca-895c-d50375137b62 Visualize unit test code coverage easily for free in Visual Studio Community Edition (and other editions too) Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines NuGet Package Manager 6.4.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/ Razor (ASP.NET Core) 17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0 Provides languages services for ASP.NET Core Razor. SQL Server Data Tools 17.0.62207.28050 Microsoft SQL Server Data Tools TypeScript Tools 17.0.10921.2001 TypeScript Tools for Microsoft Visual Studio Unitverse Extension 0.186 Generates better unit test boiler plate for existing code Visual Basic Tools 4.4.0-6.22608.27+af1e46ad38d900023f8b1a2839484e471ece1502 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used. Visual F# Tools 17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b Microsoft Visual F# Tools Visual Studio IntelliCode 2.2 AI-assisted development for Visual Studio. ```
Test CSProj ``` net472 false 10 ```
tonyhallett commented 1 year ago

Resolved. The comment above <RunSettings> was not being accounted for. Apologies for the long delay.