coverlet: Failed to get coverage result: Unable to read beyond the end of the stream
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?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (1 by maintainers)
Hello, I wanted to reopen this issue as we are experiencing the same problem using the collectors. Our package version are the following:
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:
The test projects are being run one by one. This does not happen all the time, hence our coverage is inconsistent.
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*]*"Sorry for the delay. As this is a known issue, I’m gonna close this. Thanks a lot for pointing me to the right resources. 🙂
Edit: I’m not the author of this issue. So I cannot close it.
@MarcoRossignoli it’s in a closed pr https://github.com/tonerdo/coverlet/pull/225#issuecomment-573896446
Facing the same issue. It is not consistent though.
The screenshot is from our build agent logs. When I just retry without making any changes, it works. Please let me know if you need any further info.