0

I have a x64 .NET 4.5.2 C# solution with unit tests.

Unit tests are successfully running on my dev machine, but when running on TFS build with following command:

[command]"D:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe" m:\Workspace\MyApp\Tests\MyApp.Tests\bin\x64\Release\MyApp.Tests.dll /logger:trx "/TestAdapterPath:\"m:\Workspace\"" /Platform:x64

I'm getting the following log:

Microsoft (R) Test Execution Command Line Tool Version 14.0.25420.1 Copyright (c) Microsoft Corporation. All rights reserved. Starting test execution, please wait...

5 minutes of hang and then

Error: An exception occurred while invoking executor 'executor://mstestadapter/v2': Object '/5243803c_c5e9_4f2c_bd7d_05acf3030dfa/veajeovlsl8zvqsxjaq47f1d_25.rem' has been disconnected or does not exist at the server.

This always reproduces on build server, and I managed to one time reproduce it with debbugger and got following stack trace:

System.Runtime.Remoting.RemotingException: 'Object '/5594bcf8_9093_482c_aa7b_bb6b6f25dd27/gudsmiyjksi5no4zhgahfzqu_9.rem' has been disconnected or does not exist at the server.'

>   Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsWithTestRunner(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutionRecorder testExecutionRecorder, string source, Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.UnitTestRunner testRunner)    Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTestsInSource(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.ITestExecutionRecorder testExecutionRecorder, string source, bool isDeploymentDone)   Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.ExecuteTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, bool isDeploymentDone)  Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.Execution.TestExecutionManager.RunTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle, Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.TestRunCancellationToken runCancellationToken)   Unknown
    Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll!Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.MSTestExecutor.RunTests(System.Collections.Generic.IEnumerable<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase> tests, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunContext runContext, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IFrameworkHandle frameworkHandle) Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTestInternalWithExecutors(System.Collections.Generic.IEnumerable<System.Uri> executorUris, bool hasTests, System.Collections.Generic.Dictionary<System.Uri, System.Collections.Generic.IEnumerable<string>> executorUriVsSourceList, System.Collections.Generic.Dictionary<System.Uri, System.Collections.Generic.List<Microsoft.VisualStudio.TestPlatform.ObjectModel.TestCase>> executorUriVsTestList, Microsoft.VisualStudio.TestPlatform.Core.RunContext runContext, long totalTests, Microsoft.VisualStudio.TestPlatform.Common.Utilities.MeasurementBlockWrapper mb)    Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTestsInternal(System.Collections.Generic.IEnumerable<object> testOrSources, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings runSettings, Microsoft.VisualStudio.TestPlatform.Core.TestExecutionContext executionContext) Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTests(System.Collections.Generic.IEnumerable<object> testsOrSources, Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.IRunSettings runSettings, Microsoft.VisualStudio.TestPlatform.Core.TestExecutionContext executionContext)    Unknown
    Microsoft.VisualStudio.TestPlatform.Core.dll!Microsoft.VisualStudio.TestPlatform.Core.TestExecutionManager.RunTests(object data)    Unknown
    mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)   Unknown
    mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) Unknown
    mscorlib.dll!System.Threading.ThreadHelper.ThreadStart(object obj)  Unknown

I've tried to use both Visual Studio 2015 and 2017, got same results.

My solution is using packages MSTest.TestAdapter and MSTest.TestFramework both of version 1.1.11

According to this thread: Long running unit test marked as passed fails TFS build - Object 'xxx.rem' has been disconnected or does not exist at the server.** ,

I tried to upgrade MSTest packages versions, but could never make them run locally with higher versions.

Also I've successfully run unit tests with other projects using 1.1.11 packages before.

Mugen
  • 8,301
  • 10
  • 62
  • 140
  • The solution is to use MSTest 1.1.13 or later, as the answer in the link you provided suggests. If you're having a problem getting your tests to run with that version of MSTest, I'd ask a question about how to fix *that* problem. Since you've provided no details on what that problem is, I can't make any suggestions. – Daniel Mann May 15 '18 at 02:02
  • Feel like it could be related to the agent running in TFS. Since it is working locally... – Jocke May 15 '18 at 07:27
  • @DanielMann you were right, upgrading to 1.1.18 solved the issue on build machine, still having problems locally but guessing that would be easier to solve. – Mugen May 15 '18 at 08:45

1 Answers1

3

Yeah, it's the MSTest issue on old version.

So, the solution is upgrading the MSTest to 1.1.13 or later version on the build agent machine.

Andy Li-MSFT
  • 28,712
  • 2
  • 33
  • 55