【问题标题】:How can I debug unit test in Visual Studio 2017 15.6.0如何在 Visual Studio 2017 15.6.0 中调试单元测试
【发布时间】:2018-08-18 10:13:58
【问题描述】:

全新机器,全新安装 Visual Studio 2017 Enterprise 15.6.0。 我似乎无法调试测试。我收到以下错误:

Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Failed to launch testhost with error: System.AggregateException: One or more errors occurred. () ---> Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.LaunchCustomHost(TestProcessStartInfo testProcessStartInfo)
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestHostLauncher.LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.<>c__DisplayClass37_0.<LaunchTestHostAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.<LaunchTestHostAsync>d__37.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken)
---> (Inner Exception #0) Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeClient.LaunchCustomHost(TestProcessStartInfo testProcessStartInfo)
   at Microsoft.VisualStudio.TestPlatform.Client.DesignMode.DesignModeTestHostLauncher.LaunchTestHost(TestProcessStartInfo defaultTestHostStartInfo)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.<>c__DisplayClass37_0.<LaunchTestHostAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting.DotnetTestHostManager.<LaunchTestHostAsync>d__37.MoveNext()<---

   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyOperationManager.SetupChannel(IEnumerable`1 sources, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Client.ProxyExecutionManager.StartTestRun(TestRunCriteria testRunCriteria, ITestRunEventsHandler eventHandler)
 Summary: Passed: 0, Failed: 0, Ignored: 0
Duration: 4.82 seconds

我可以运行测试,但我需要逐步调试通过我的测试。

【问题讨论】:

  • 用粗体字大声呼救可能会产生与您想象的不同的效果。否则,欢迎来到 SO!
  • 使用帮助 > 发送反馈 > 报告问题,让他们知道 15.6.0 的错误。
  • @elgonzo 谢谢!
  • 上面提到要断开VPN。对我来说是相反的。调试仅在已连接时起作用。

标签: c# unit-testing visual-studio-2017 .net-core


【解决方案1】:

如果您使用VPN连接,请先断开VPN,然后关闭VS2017并重新打开

【讨论】:

    【解决方案2】:

    如果您使用的是 VS2017,请将您的项目更新为使用 netcore 2.0 即可。

    在安装 VS2017 并尝试调试我使用 netcore 1.0 创建的项目后遇到了同样的问题。

    【讨论】:

      【解决方案3】:

      我在使用 Windows 10 进行新安装时经常遇到此问题。通常是在我的单元测试类中添加/删除其他测试/方法之后。

      这是 VS 15.9.5 和 ASP.Net Core 2.2

      重新启动 Visual Studio 会修复它,直到下一次。

      【讨论】:

        【解决方案4】:

        就我而言,

        重新打开 VS2017停止 Live Unit Testing 会起作用!

        顺便说一句,我正在使用 .NET.Core2.1 webApi 项目。

        【讨论】:

          【解决方案5】:

          以管理员身份运行 VS,解决了我的问题。

          【讨论】:

            【解决方案6】:

            对我来说,通过清除缓存解决了问题

            C:\Users\mdasari\AppData\Local\NuGet, C:\Users\mdasari.nuget

            清理解决方案,然后运行测试用例

            【讨论】:

              猜你喜欢
              • 2018-05-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2016-10-30
              • 2017-08-09
              • 2017-08-13
              • 1970-01-01
              • 1970-01-01
              相关资源
              最近更新 更多