Skip to content

Using runsettings means sometimes missing coverage info #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
queen-of-code opened this issue Sep 27, 2019 · 8 comments
Closed

Using runsettings means sometimes missing coverage info #571

queen-of-code opened this issue Sep 27, 2019 · 8 comments
Labels
needs more info More details are needed

Comments

@queen-of-code
Copy link

I've traced down a harrowing issue with missing code coverage on our build server down to the use of runsettings vs directly invoking the cross-plat coverage via the dotnet test command line.

The repro is very simple for our DLL - of SPECIAL note is that this is the same csproj + test csproj combo that previously was not reporting code coverage before the recent advent of collectors. MOST of our test projects do not have this issue.

Works Fine:
dotnet test --collect:"XPlat Code Coverage"
Output:

<class name="AttributionStrategyBase/&lt;&gt;c__DisplayClass10_0" filename="C:\\src\Sdk\Attribution\AttributionStrategyBase.cs" line-rate="1" branch-rate="0.8636" complexity="22">

Does Not Work:
dotnet test --settings ..\coverlet.runsettings
Output:

        <Class>
          <Summary numSequencePoints="0" visitedSequencePoints="0" numBranchPoints="22" visitedBranchPoints="0" sequenceCoverage="100" branchCoverage="0" maxCyclomaticComplexity="22" minCyclomaticComplexity="22" visitedClasses="0" numClasses="1" visitedMethods="0" numMethods="0" />
          <FullName>Attribution.AttributionStrategyBase/&lt;&gt;c__DisplayClass10_0</FullName>
          <Methods />
        </Class>

Contents of Runsettings file (I've tried with includes and excludes and all combinations thereof):

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat Code Coverage">
        <Configuration>
          <Format>cobertura</Format>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
</RunSettings>

The test csproj has the following versions:

  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" />
    <PackageReference Include="coverlet.collector" Version="1.0.*"/>
    <PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="TeamCity.VSTest.TestAdapter" Version="1.0.15" />
    <PackageReference Include="xunit" Version="2.4.1" />
    <PackageReference Include="Moq" Version="4.10.1" />
  </ItemGroup>

And we are using dotnet core sdk 3.0.100

@MarcoRossignoli MarcoRossignoli added the needs more info More details are needed label Sep 28, 2019
@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Sep 28, 2019

@queen-of-code can you provide a repro?
I did some test on my local with and without runsettings but I cannot repro.
My repro with your settings issue571.zip (run ...\issue571\XUnitTestProject1\run.cmd")

@MarcoRossignoli
Copy link
Collaborator

Oh one more thing you should upgrade collector to new version https://www.nuget.org/packages/coverlet.collector/

@queen-of-code
Copy link
Author

I'll try an upgrade. But are you at least able to repro the two very different formats regardless of coverage numbers? Because that's a clean + easy repro for me and should be the same for you.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Oct 3, 2019

But are you at least able to repro the two very different formats regardless of coverage numbers?

No...can you provide a repro?

image

@MarcoRossignoli
Copy link
Collaborator

@queen-of-code when you update the version to 1.1.0 you need to provide runsettings file with a InProcDataCollectors config because i found and issue on vstest plat collector load and we cannot fix on our side at the moment #576 (comment)

<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
  <DataCollectionRunSettings>
    <DataCollectors>
      <DataCollector friendlyName="XPlat code coverage">
        <Configuration>
          <Format>cobertura</Format>
        </Configuration>
      </DataCollector>
    </DataCollectors>
  </DataCollectionRunSettings>
  <InProcDataCollectionRunSettings>
    <InProcDataCollectors>
      <InProcDataCollector assemblyQualifiedName="Coverlet.Collector.DataCollection.CoverletInProcDataCollector, coverlet.collector, Version=1.1.0.0, Culture=neutral, PublicKeyToken=null"
                     friendlyName="XPlat Code Coverage"
                     enabled="True"
                     codebase="coverlet.collector.dll" />
    </InProcDataCollectors>
  </InProcDataCollectionRunSettings>
</RunSettings>

@queen-of-code
Copy link
Author

I'm testing with this now to see if it helps.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jan 2, 2020

@queen-of-code any news?
Feel free to close if solved.

@MarcoRossignoli
Copy link
Collaborator

Close for stale conversation.
Feel free to re-open if needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs more info More details are needed
Projects
None yet
Development

No branches or pull requests

2 participants