Skip to content
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

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

Closed
AlexDenton opened this issue Jan 30, 2020 · 17 comments
Closed
Labels
Known Issue It's a know issue

Comments

@AlexDenton
Copy link

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?

@MarcoRossignoli
Copy link
Collaborator

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

No

Are you sure to setup all correctly? https://github.com/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md
If so can you share your test project csproj?

@MarcoRossignoli MarcoRossignoli added the needs more info More details are needed label Jan 31, 2020
@AlexDenton
Copy link
Author

It's been working well on build agents so I think it maybe something with my local setup. I'll see if I can reproduce tomorrow.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Feb 4, 2020

Be sure to update test sdk package to preview (for now) like in the sample on guide otherwise in process collector won't be loaded and you'll could hit that issue. That issue is randomic and depends on timing and machine load.

@MarcoRossignoli
Copy link
Collaborator

any news?

@prashanth-nani
Copy link

Facing the same issue. It is not consistent though.

image

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.

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Feb 28, 2020

@prashanth-nani can you show you test project references and the command line you use to run coverage?
Sorry you're hitting known issue for msbuild...you have to use collectors
Issue https://github.com/tonerdo/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test
Collectors https://github.com/tonerdo/coverlet/blob/master/Documentation/VSTestIntegration.md
Collectors today doesn't support merge

@MarcoRossignoli
Copy link
Collaborator

@pape77 I cannot find your workaround to use merge with current version of collector...can you paste the link here?

@pape77
Copy link
Contributor

pape77 commented Feb 29, 2020

@MarcoRossignoli it's in a closed pr
#225 (comment)

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Feb 29, 2020

Thank's, @prashanth-nani if you want to use merge with collector(that feat was hidden because is not so easy to use/understand at the moment) you can use Daniel trick!

@prashanth-nani
Copy link

Thanks @MarcoRossignoli, I'll take a look at it.

@MarcoRossignoli
Copy link
Collaborator

@prashanth-nani any news?Feel free to close if solved!

@prashanth-nani
Copy link

prashanth-nani commented May 18, 2020

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
Copy link
Collaborator

Close for stale conversation and solved issue, feel free to reopen if needed!

@MarcoRossignoli MarcoRossignoli added Known Issue It's a know issue and removed needs more info More details are needed labels May 18, 2020
@orbus-dkreivenas
Copy link

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.

@MarcoRossignoli
Copy link
Collaborator

Pls can you open a new issue with same infos?

@agray
Copy link

agray commented 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*]*"

@MarcoRossignoli
Copy link
Collaborator

MarcoRossignoli commented Jul 29, 2020

@agray you should try to use collector integration that is a known issue for msbuild integration https://github.com/coverlet-coverage/coverlet/blob/master/Documentation/KnownIssues.md#1-vstest-stops-process-execution-earlydotnet-test

Please open new issue if issue persist also after collectors switch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Known Issue It's a know issue
Projects
None yet
Development

No branches or pull requests

6 participants