question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to get coverage result: Unable to read beyond the end of the stream

See original GitHub issue

Despite following the recommendation of using the following command:

dotnet test --collect:"XPlat Code Coverage"

Because of this known issue https://github.com/tonerdo/coverlet/blob/master/Documentation/KnowIssues.md#1-vstest-stops-process-execution-earlydotnet-test

I still seem to be getting the same issue.

Data collector 'XPlat code coverage' message: [coverlet]Coverlet.Collector.Utilities.CoverletDataCollectorException: CoverletCoverageDataCollector: Failed to get coverage result
 ---> System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
   at System.IO.BinaryReader.InternalRead(Int32 numBytes)
   at Coverlet.Core.Coverage.CalculateCoverage() in D:\git\coverletToRelease\src\coverlet.core\Coverage.cs:line 363
   at Coverlet.Core.Coverage.GetCoverageResult() in D:\git\coverletToRelease\src\coverlet.core\Coverage.cs:line 137
   at Coverlet.Collector.DataCollection.CoverageWrapper.GetCoverageResult(Coverage coverage) in D:\git\coverletToRelease\src\coverlet.collector\DataCollection\CoverageWrapper.cs:line 44
   at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in D:\git\coverletToRelease\src\coverlet.collector\DataCollection\CoverageManager.cs:line 91
   --- End of inner exception stack trace ---
   at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in D:\git\coverletToRelease\src\coverlet.collector\DataCollection\CoverageManager.cs:line 96
   at Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionEnd(Object sender, SessionEndEventArgs e) in D:\git\coverletToRelease\src\coverlet.collector\DataCollection\CoverletCoverageCollector.cs:line 148.

Is it expected that by using this method I should never get the Unable to read beyond the end of the stream error?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
agraycommented, Jul 29, 2020

Please reopen. Getting the same error. dotnet version: 3.1.302

Command: bat "${env.DOTNET_EXE} test MyTestProject.csproj --no-restore -c Release /p:CollectCoverage=true /p:CoverletOutput=${env.WORKSPACE}/${env.UT_RESULTS} /p:CoverletOutputFormat=opencover /p:Threshold=50 /p:ThresholdType=branch /p:ThresholdStat=Average /p:Exclude=[*Test*]*"

2reactions
orbus-dkreivenascommented, Jul 8, 2020

Hello, I wanted to reopen this issue as we are experiencing the same problem using the collectors. Our package version are the following:

  • coverlet.collectors 1.3.0
  • Microsoft.NET.Test.Sdk 16.6.1
  • Tests projects target netcoreapp2.2
  • dotnet sdk 3.1.301
  • Microsoft Test Execution Command Line Tool Version 16.6.0 (displayed in the test logs)

We run the tests by running dotnet test {CS Project} --no-build --no-restore --logger trx --collect "XPlat Code Coverage".

The error we receive is:

Data collector 'XPlat code coverage' message: [coverlet]Coverlet.Collector.Utilities.CoverletDataCollectorException: CoverletCoverageDataCollector: Failed to get coverage result
 ---> System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
   at System.IO.BinaryReader.InternalRead(Int32 numBytes)
   at Coverlet.Core.Coverage.CalculateCoverage() in /_/src/coverlet.core/Coverage.cs:line 367
   at Coverlet.Core.Coverage.GetCoverageResult() in /_/src/coverlet.core/Coverage.cs:line 141
   at Coverlet.Collector.DataCollection.CoverageWrapper.GetCoverageResult(Coverage coverage) in /_/src/coverlet.collector/DataCollection/CoverageWrapper.cs:line 44
   at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in /_/src/coverlet.collector/DataCollection/CoverageManager.cs:line 93
   --- End of inner exception stack trace ---
   at Coverlet.Collector.DataCollection.CoverageManager.GetCoverageResult() in /_/src/coverlet.collector/DataCollection/CoverageManager.cs:line 98
   at Coverlet.Collector.DataCollection.CoverletCoverageCollector.OnSessionEnd(Object sender, SessionEndEventArgs e) in /_/src/coverlet.collector/DataCollection/CoverletCoverageCollector.cs:line 160.

The test projects are being run one by one. This does not happen all the time, hence our coverage is inconsistent.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to read beyond the end of the stream · Issue #865
We have a solution with multiple projects, but this happens not always at the same project. Coverlet version: coverlet.msbuild:2.8.1. Test SDK ...
Read more >
Error 'Unable to read beyond the end of the stream. ' in CL ...
Hello,. starting from yesterday we are encountering the following error during build test and collecting test results. Calculating coverage ...
Read more >
Error running unit tests on azure devops with nugget ...
1.Clean the package cache, delete the bin and obj folder and run the dotnet test command again. 2.Update coverlet.msbuild package from 2.3.1 to ......
Read more >
Unable to read beyond the end of the stream
Unable to read beyond the end of the stream - I have NCover generating two code coverage files, merging them and creating a...
Read more >
Developers - Unable to read beyond the end of the stream -
I use the latest versions but still have this error. cmd. dotnet.exe test --logger trx --results-directory .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found