我有一个带有单元测试的x64 .NET 4.5.2 C#
解决方案。
单元测试在我的开发计算机上成功运行,但在 TFS 生成上运行时,使用以下命令:
[command]"D:Program Files (x86)Microsoft Visual Studio 14.0Common7IDECommonExtensionsMicrosoftTestWindowvstest.console.exe" m:WorkspaceMyAppTestsMyApp.Testsbinx64ReleaseMyApp.Tests.dll /logger:trx "/TestAdapterPath:"m:Workspace"" /Platform:x64
我收到以下日志:
Microsoft (R( 测试执行命令行工具版本 14.0.25420.1 版权所有 (c( Microsoft公司。 保留所有权利。开始 测试执行,请稍候...
5分钟挂起,然后
错误:调用执行程序时发生异常 "executor://mstestadapter/v2":对象 '/5243803c_c5e9_4f2c_bd7d_05acf3030dfa/veajeovlsl8zvqsxjaq47f1d_25.rem' 服务器已断开连接或不存在。
这总是在构建服务器上重现,我设法使用 debbugger 重现了一次并得到了以下堆栈跟踪:
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
我尝试同时使用Visual Studio 2015
和2017
,得到了相同的结果。
我的解决方案是使用MSTest.TestAdapter
和MSTest.TestFramework
版本 1.1.11 的包
根据此线程:标记为通过的长时间运行的单元测试失败 TFS 生成 - 对象"xxx.rem"已断开连接或服务器上不存在。
我尝试升级MSTest
包版本,但永远无法使它们以更高版本在本地运行。
此外,我之前也使用 1.1.11 包成功地对其他项目运行单元测试。
是的,这是旧版本上MSTest的问题。
因此,解决方案是在生成代理计算机上将 MSTest 升级到 1.1.13 或更高版本。