coverlet: Test's not working when using Coverlet Collector

Hi,

I’m trying to use the coverlet collector and it does not exit the tests. I have 85 tests that take about 35 seconds to run. But when I run dotnet test --collect:"XPlat Code Coverage" it runs forever I have to manually close the process. Coverlet is working fine.

The project is in dot net 5.0.

Coverlet output Calculating coverage result… Generating report ‘ERP.Service.xUnit.Test\coverage.json’ ±------------------------------±-------±-------±-------+ | Module | Line | Branch | Method | ±------------------------------±-------±-------±-------+ | ERP.Core | 38.81% | 3.19% | 19.8% | ±------------------------------±-------±-------±-------+ | ERP.Infrastructure | 0% | 0% | 0% | ±------------------------------±-------±-------±-------+ | ERP.Repositories | 20.28% | 24.1% | 34.23% | ±------------------------------±-------±-------±-------+ | ERP.Services | 38.02% | 23.25% | 32.46% | ±----------------------------±-------±-------±-------+ | ERP.Services.xUnit.Test | 99.82% | 90.62% | 99% | ±------------------------------±-------±-------±-------+

±--------±-------±-------±-------+ | | Line | Branch | Method | ±--------±-------±-------±-------+ | Total | 0.1% | 20.65% | 19.06% | ±--------±-------±-------±-------+ | Average | 39.38% | 28.23% | 37.09% | ±--------±-------±-------±-------+

Output for dotnet test --collect:“XPlat Code Coverage”

Starting test execution, please wait… A total of 1 test files matched the specified pattern.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 33

Most upvoted comments

I definitely would not lose sleep over it unless you want a huge challenge. Software should not be designed this was in 2021!

I’m migrating the code to Clean Acrutature so everything should have its own service class exposed by an interface. Done 5k lines 95k more to go

The web project is full of static references tends of thousands. If you build on an Intel i5 the build time is 30 minutes

Which version of coverlet are you using? Can you zip and send logs also for dotnet test /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura same diag config.

Not needed…looks like it hangs on collector during report generation…but from logs isn’t possible understand where it stucks we need to get a dump.

In log.datacollector.21-11-06_13-48-31_56943_5.txt after hit file deletion(second to last line) we expect generation of file but it stucks until parent process exits(I think when you stop with ctrl+c on console).

You should run the test and when it hangs(some seconds) you should find a process called datacollector.exe as child of dotnet.exe that is the process for which to take the dump. After you should open in VS and take a look at stacks.

A normal log should be something like

TpTrace Verbose: 0 : 12296, 1, 2021/11/06, 15:58:05.190, 9120886030, datacollector.dll, [coverlet]Hit file 'C:\Users\mrossignoli\AppData\Local\Temp\ClassLibrary1_caa2c8d8-0589-4152-a05c-4e34193c1914' deleted
...
TpTrace Information: 0 : 12296, 1, 2021/11/06, 15:58:05.226, 9121246374, datacollector.dll, [coverlet]CoverletCoverageDataCollector: Saved coverage report to path: 'C:\Users\mrossignoli\AppData\Local\Temp\87c78d9c-a39d-40ef-8da0-420f0414bd86\coverage.cobertura.xml'
...
TpTrace Information: 0 : 22504, 1, 2021/11/06, 15:58:05.234, 9121329227, datacollector.dll, DataCollectionRequestHandler.ProcessRequests : DataCollection completed

in your case

TpTrace Verbose: 0 : 3376, 1, 2021/11/06, 13:49:53.691, 1527661733144, datacollector.dll, [coverlet]Hit file 'C:\Users\User\AppData\Local\Temp\Project.Core_ac8c1e45-e7fb-4b6c-9bc8-9279b142e04b' deleted
TpTrace Information: 0 : 3376, 5, 2021/11/06, 14:04:01.677, 1536141587252, datacollector.dll, DataCollector: ParentProcess '18396' Exited.