0

首先我的设置:

  • .Net Core 3.1(从 2.2 迁移而来)
  • xUnit 2.4.1
  • xUnit Runner 2.4.1
  • 视觉工作室 2019 16.4.2
  • 测试.SDK 16.4.0

我刚刚从 .Net Core 2.2 迁移到 3.1。我刚刚修复了错误并将我的序列化程序更改为 System.Text。我的应用程序运行良好,但...

注意:我所有的测试都是使用WebApplicationFactory.

我一直在使用 Visual Studio Test Runner 来运行所有测试,但是当我尝试 Run All 时出现错误:

请注意,netcoreapp2.2我在 MyTests 和 MyApp 项目中专门使用 .Net Core 3.1 时很奇怪。

[10.01.2020 2:05:03.939 PM] System.InvalidOperationException: The following TestContainer was not found 'D:\Projects\MyApp\MyTests\bin\Debug\netcoreapp2.2\GrabGoApiTests.dll'
   at Microsoft.VisualStudio.TestWindow.Client.TestContainer.TestContainerProvider.<GetTestContainerAsync>d__46.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.TestContainerConfigurationQueryByTestsBase.<QueryTestContainerConfigurationsAsync>d__6.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.TestContainerConfigurationQuery.<GetTestContainerConfigurationsAsync>d__16.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.TestRunConfiguration.<UpdateAsync>d__13.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.RunOperation.<RunTestsAsync>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.Operation.<<Execute>b__37_0>d.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.Extensibility.ILoggerExtensions.<CallWithCatchAsync>d__10`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

然后我在想“好吧......也许 VS 再次表现得很奇怪我会尝试从控制台运行测试”

PS D:\Projekty\GrabGoAPI> dotnet test
Test run for D:\Projects\MyApp\MyTests\bin\Debug\netcoreapp3.1\GrabGoApiTests.dll(.NETCoreApp,Version=v3.1)
Microsoft (R) Test Execution Command Line Tool Version 16.3.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...

A total of 1 test files matched the specified pattern.
The active test run was aborted. Reason: Test host process crashed : Stack overflow.


Test Run Aborted.
Total tests: Unknown
     Passed: 101
 Total time: 26,3009 Seconds

现在我在这里。

我发现。但我无法在 Visual Studio 中调试测试以找出导致问题的测试。

每次dotnet test --blame都指责随机测试。

如何找到导致 StackOverflow 异常的原因?

4

3 回答 3

3

我得到了这个错误,它是由一些重构后调用自身的方法引起的,所以谢谢你的测试。

于 2021-06-01T09:54:46.877 回答
1

我是因为 System.Text.Json 没有Reference LoopJSON.Net以前那样处理。

更改为 JSON.Net 有所帮助。

于 2020-01-16T11:05:58.053 回答
0

我通过安装Microsoft.NET.Test.Sdk解决了这个问题。

  1. 打开工具选项卡
  2. 选择NuGet 包管理器子菜单
  3. 单击解决方案菜单项的管理NuGet 包
  4. 安装Microsoft.NET.Test.Sdk
于 2020-07-16T06:55:14.887 回答