coverlet: Coverlet crashes VSTest

I’m getting errors when I’m trying to use the vstest integration to coverlet.

This is with the 2.2.300 SDK.

 PS> dotnet test --no-build --no-restore --settings ..\CodeCoverage.runsettings --collect:"XPlat Code Coverage"  -- RunConfiguration.DisableAppDomain=true
Test run for D:\dev\xUnit\visualstudio.xunit\test\test.xunit.runner.visualstudio\bin\Debug\net46\test.xunit.runner.visualstudio.dll(.NETFramework,Version=v4.6)
Microsoft (R) Test Execution Command Line Tool Version 16.1.1
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...


Attachments:
  D:\dev\xUnit\visualstudio.xunit\test\test.xunit.runner.visualstudio\TestResults\730034da-8dc8-4a52-9bdf-db094514cf10\coverage.cobertura.xml
  D:\dev\xUnit\visualstudio.xunit\test\test.xunit.runner.visualstudio\TestResults\730034da-8dc8-4a52-9bdf-db094514cf10\Oren_ATHENA_2019-06-25.16_25_17.coverage

Test Run Aborted.

To repro:

  • clone https://github.com/xunit/visualstudio.xunit
  • checkout the coverlet branch
  • from a VS Command prompt, go to the /test/test.xunit.runner.visualstudio directory
  • run msbuild /restore to build the test project (and the project it’s testing). You’ll need the Windows/UWP 16299 SDK installed to successfully build it.
  • From the same directory, run the following command dotnet test --no-build --no-restore --settings ..\CodeCoverage.runsettings --collect:"XPlat Code Coverage" -- RunConfiguration.DisableAppDomain=true

It’ll start running the tests and then abort.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

@onovotny So I have looked at this. In your runsettings you define both data collectors “CodeCoverage” and “Xplat Code coverage” I tried both, and both of them are aborting the run. I don’t have an RCA on the CodeCoverage one but for xplat code coverage, here’s my analysis.

In test.xunit.runner.visualstudio, there’s a condition

  <ItemGroup Condition=" '$(TargetFramework)' == 'net46' ">
    <PackageReference Include="Microsoft.TestPlatform.ObjectModel" Version="15.9.0" />
  </ItemGroup>

This is causing it to refer to old objectmodel which does not work with coverlet. Getting this error when I looked at logs using --diag option

Microsoft.VisualStudio.TestPlatform.ObjectModel.DataCollection.SessionStartEventArgs..ctor(System.Collections.Generic.IDictionary`2<System.String,System.Object>)'.
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.EventHandlers.TestCaseEventsHandler.SendSessionStart(IDictionary`2 properties)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.RunTestsWithSources.SendSessionStart()
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Execution.BaseRunTests.RunTests().

Can you try with updating the object model and disabling data collector for CodeCoverage and see if xplat code coverage works?

cc: @MarcoRossignoli

@MarcoRossignoli @onovotny I’ll try to repro the issue and get back.