azure.net-coreazure-pipelinescicddotnet-tool

Azure pipeline dotnet test error ---> System.Exception: Unable to read beyond the end of the stream


When running dotnet test on the Azure Pipeline, the pipeline fails with error:

System.Exception: Unable to read beyond the end of the stream.
   at System.IO.BinaryReader.Read7BitEncodedInt()
   at System.IO.BinaryReader.ReadString()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.LengthPrefixCommunicationChannel.NotifyDataAvailable()
   at Microsoft.VisualStudio.TestPlatform.CommunicationUtilities.TcpClientExtensions.MessageLoopAsync(TcpClient client, ICommunicationChannel channel, Action`1 errorHandler, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---.
##[error]Error: The process '/opt/hostedtoolcache/dotnet/dotnet' failed with exit code 1

The best link I could find at GitHub issue says,

_ This is expected, any testhost disconnect, is considered a crash/abort, unless vstest.console told that testhost that it is okay to exit. Your test stops the testhost, and with that, it also stops the test framework, adapter, and other logic responsible for sending back the data. So that is a crash from the point of view of vstest.console. _

But I couldn't find a solution to resolve it on my pipeline.

Any help would be appreciated


Solution

  • Here the issue was that one of the tests were failing and that caused the failure.

    Adding to the problems there was a try block which catches nothing and hence there was no trace of the test failure( which is of course weird// we should never have used try catch in tests). Obviously none of the tests "failed" and that made the debugging difficult. So the system failed with:

    Test Run Aborted with error System.Exception: One or more errors occurred.
    

    which is not very intuitive.