【问题标题】:visual studio 2017 c++ native unit test framework not workingVisual Studio 2017 C++本机单元测试框架不起作用
【发布时间】:2018-03-27 11:39:57
【问题描述】:

场景如下:

  1. 我创建了一些解决方案,Windows x64 控制台应用程序
  2. 我写了一些类,主文件等,没什么特别的
  3. 我在此解决方案中创建测试项目
  4. 我更改了解决方案属性:所有平台都改为 x64(这似乎没有改变任何东西,只是说)

就是这样,我不会添加任何对测试项目的引用。我将 VS 生成的所有内容都保留在测试项目文件中因为我想构建测试项目它失败了,我得到了以下堆栈:

[2018-03-27 13:32:48 Informational] ------ Discover test started ------
[2018-03-27 13:32:48 Error] System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformV2()
[2018-03-27 13:32:48 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
[2018-03-27 13:32:48 Informational] ========== Discover test finished: 0 found (0:00:00,0055039) ==========
[2018-03-27 13:32:48 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<ExecuteRequest>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Wait(Int32 timeout)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose(Boolean disposing)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose()
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteRequestAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoveryOperation.<StartDiscoverTests>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoverSelectedOperation.<ExecuteInternal>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteWithEvents>d__40.MoveNext()
[2018-03-27 13:33:22 Informational] ------ Discover test started ------
[2018-03-27 13:33:22 Warning] Test run will use DLL(s) built for framework Framework45 and platform X86. Following DLL(s) will not be part of run: 
UnitTest1.dll is built for Framework None and Platform X64.
 Go to http://go.microsoft.com/fwlink/?LinkID=236877&clcid=0x409 for more details on managing these settings.
[2018-03-27 13:33:22 Error] System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformV2()
[2018-03-27 13:33:22 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
[2018-03-27 13:33:22 Informational] ========== Discover test finished: 0 found (0:00:00,003502) ==========
[2018-03-27 13:33:22 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<ExecuteRequest>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Wait(Int32 timeout)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose(Boolean disposing)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose()
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteRequestAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoveryOperation.<StartDiscoverTests>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoverSelectedOperation.<ExecuteInternal>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteWithEvents>d__40.MoveNext()
[2018-03-27 13:36:04 Informational] ------ Discover test started ------
[2018-03-27 13:36:04 Error] System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformV2()
[2018-03-27 13:36:04 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
[2018-03-27 13:36:04 Informational] ========== Discover test finished: 0 found (0:00:00,0030025) ==========
[2018-03-27 13:36:04 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<ExecuteRequest>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Wait(Int32 timeout)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose(Boolean disposing)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose()
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteRequestAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoveryOperation.<StartDiscoverTests>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoverSelectedOperation.<ExecuteInternal>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteWithEvents>d__40.MoveNext()
[2018-03-27 13:36:12 Informational] ------ Discover test started ------
[2018-03-27 13:36:12 Error] System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformV2()
[2018-03-27 13:36:12 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
[2018-03-27 13:36:12 Informational] ========== Discover test finished: 0 found (0:00:00,0035031) ==========
[2018-03-27 13:36:12 Error] System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.VisualStudio.TestWindow.VsAdapters.UnitTestExtensionDiscoverer.GetAllEnabledExtensions(ILogger log)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.UpdateTestPlatform(Lazy`1 testPlatform)
   at Microsoft.VisualStudio.TestWindow.Controller.TestPlatformProvider.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.GetTestPlatformBySettings(ITestExecutorLauncher testExecutorLauncher, String testRunSettings, Boolean isAppContainer)
   at Microsoft.VisualStudio.TestWindow.Controller.TestDiscoveryRequest.<CreateRequests>d__16.MoveNext()
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<RunRequests>d__98.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.<ProcessRequest>d__97.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<ExecuteRequest>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Wait(Int32 timeout)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose(Boolean disposing)
   at Microsoft.VisualStudio.TestWindow.Controller.Request.Dispose()
   at Microsoft.VisualStudio.TestWindow.Controller.RequestFactory.<Execute>d__11.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteRequestAsync>d__38.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoveryOperation.<StartDiscoverTests>d__15.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.DiscoverSelectedOperation.<ExecuteInternal>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.TestWindow.Controller.Operation.<ExecuteWithEvents>d__40.MoveNext()

我已经找了一段时间了,有人知道那里出了什么问题吗?我在 2 个不同的 VS 解决方案上对其进行了测试,结果相同。请帮忙!

【问题讨论】:

  • @AlBundy 抱歉,我有点累了,我更正了 2 个错别字,我们可以继续解决实际问题吗?
  • 日志显示test started 和test finished。描述显示As I want to build test project it fails。我怀疑你做了你所描述的。
  • 我之所以这么写是因为当我构建不运行测试时会显示错误堆栈。所以BUILDING失败了,对吧?它还说:0 found 但是有一个空测试,所以它没有做它的工作,是吗?此外,在测试资源管理器中,进度条无限移动,没有任何结果。
  • @CharlieB - 如果您使用的是 15.5.x 版本(对于 x > 某些东西),它就不起作用。尝试升级到 15.6
  • @BoPersson 我的版本是15.6.4

标签: c++ visual-studio unit-testing


【解决方案1】:

好的,我终于找到了解决方案。我所要做的就是转到Testee Project properties -> Configuration Properties -> General 并将配置类型从.exe. 更改为.lib - 静态库。干杯!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    • 2011-07-12
    • 1970-01-01
    • 2017-08-13
    相关资源
    最近更新 更多