vstest.console.exe - no .trx files are generated

aik 20 Reputation points
2024-01-25T10:10:35.5366667+00:00

Hello, I have issue with running tests - I cannot find tests result.

Tests are built in VS2022, .NET Framework 4.8.1.

Test adapter MSTest.TestAdapter 3.1.1, MS.TestFramework 3.1.1.

To run tests I use vstest.console.exe v. 17.4.1.

I am running the tests on virtual machine via command

"C:\Program Files (x86)\Microsoft Visual Studio\2022\TestAgent\Common7\IDE\Extensions\TestPlatform\vstest.console.exe" C:\tests\Tests.dll /ResultsDirectory:TestResults /logger:trx /Tests:TestClass

All tests passed. However, there is no result file (.trx) in TestResults. Only new folder with subfolders In and Out is created and these are empty. I have also tried another vstest.console.exe (v. 17.0.33006.217) which is located at:

"C:\Program Files (x86)\Microsoft Visual Studio\2022\TestAgent\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe"

but with the same issue. When I run test in a separate process (/InIsolation), the tests passed, .trx is generated but I get this error (result path is modified):

"The active test run was aborted. Reason: Test host process crashed Results File: ...result.trx Test Run Aborted with error System.AggregateException: One or more errors occurred. ---> System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) --- End of inner exception stack trace --- at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) at System.IO.Stream.ReadByte() at System.IO.BinaryReader.ReadByte() 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 ---."

Visual Studio Testing
Visual Studio Testing
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Testing: The act or process of applying tests as a means of analysis or diagnosis.
329 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Tianyu Sun-MSFT 27,356 Reputation points Microsoft Vendor
    2024-01-26T05:31:24.8966667+00:00

    Hello @aik,

    Welcome to Microsoft Q&A forum.

    I believe something stops the test results file from being generated on your side.

    The command and the vstest.console.exe tool you are using is correct(have tested on my side).

    I’m not sure if this is related to memory(maybe out of memory), or some special installed applications(which may kill the process). To narrow down this issue, I suggest you try to create a very simple test project, use the same command parameters to test and see if the test results file will be generated correctly.

    Best Regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.