我有一个x64 .NET 4.5.2 C#
单元测试解决方案。
单元测试在我的开发机器上成功运行,但是在使用以下命令在TFS构建上运行时:
[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
我收到以下日志:
Microsoft(R)测试执行命令行工具版本14.0.25420.1 版权所有(c)Microsoft Corporation。版权所有。开始 测试执行,请稍候...
挂起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
,结果相同。
我的解决方案是使用版本1.1.11的包MSTest.TestAdapter
和MSTest.TestFramework
我尝试升级MSTest
软件包版本,但永远不会让它们在本地运行更高版本。
此外,我之前使用1.1.11软件包成功运行了其他项目的单元测试。
答案 0 :(得分:2)
是的,这是旧版本的MSTest问题。
因此,解决方案是在构建代理计算机上将MSTest升级到1.1.13或更高版本。