0

在将解决方案转换为 Visual Studio 2012(以前的版本是 Visual Studio 2010)后,我尝试在解决方案中运行单元测试。现在 testrunner 在执行单个测试之前崩溃。我收到一条相当笼统的错误消息。如果我选择调试 Visual Studio,我会得到以下堆栈跟踪:

Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.AssemblyKeyExtractor.ExtractPublicKeyFromKeyFile(string keyFile, out bool isPublicKey)
[Managed to Native Transition]
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.PublicKeyHolder.this[string].get(string file)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.DeploymentHelper.GetPublicKey(string keyFile, Microsoft.VisualStudio.TestTools.TestManagement.PublicKeyHolder publicKeyHolder)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.DeploymentHelper.ProcessCodeCoverageItemsForDeployment(System.Collections.Generic.List<Microsoft.VisualStudio.TestTools.TestManagement.DeploymentCoverageItem> deploymentCoverageItems)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager.DoDeployment(Microsoft.VisualStudio.TestTools.Common.TestRun run, Microsoft.VisualStudio.TestTools.Common.FileCopyService fileCopyService)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.SetupTestRun(Microsoft.VisualStudio.TestTools.Common.TestRun run, bool isNewTestRun, Microsoft.VisualStudio.TestTools.Common.FileCopyService fileCopyService, Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager deploymentManager)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.SetupRunAndListener(Microsoft.VisualStudio.TestTools.Common.TestRun run, Microsoft.VisualStudio.TestTools.Common.FileCopyService fileCopyService, Microsoft.VisualStudio.TestTools.TestManagement.DeploymentManager deploymentManager)
Microsoft.VisualStudio.QualityTools.TMI.dll!Microsoft.VisualStudio.TestTools.TestManagement.ControllerProxy.QueueTestRunWorker(object state)
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(object state)
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state, bool preserveSyncCtx)
mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch()
mscorlib.dll!System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
[Native to Managed Transition]

堆栈跟踪表明我正在测试签名程序集这一事实可能会触发错误。

4

1 回答 1

0

经过一番试验,我发现我可以通过在测试运行配置文件中禁用测试运行的代码覆盖来解决这个问题。您可以通过打开 LocalTestRun.testrunco​​nfig 文件(位于解决方案项下)-> 数据和诊断然后禁用“代码覆盖率(Visual Studio 2010)”来执行此操作

于 2013-03-13T14:02:14.923 回答