c# - 如何确定导致 Test Explorer 崩溃的异常?

标签 c# visual-studio nunit visual-studio-2017 test-explorer

当我在以前版本的 Visual Studio 测试资源管理器中运行测试时,出现了导致构建运行器崩溃的问题(例如 AccessViolationExceptionStackOverflowExceptionOutOfMemoryException 等),它会输出一条消息,显示抛出的异常类型以及如何启用日志以获取更多详细信息。

使用 Visual Studio 2017 Community Edition 版本 15.3.2 和 .NET Core 1.0,当发生崩溃时,测试输出中显示的所有内容为:

[8/30/2017 3:03:42 AM Error] The active Tests Run was aborted.

[8/30/2017 3:03:42 AM Informational] ========== Run test finished: 1030 run (0:41:12.5762484) ==========

如何确定导致构建运行器崩溃的异常类型(最好使用堆栈跟踪)?

注意:我打开了一个issue with NUnit在此调查期间询问如何确定哪些测试导致了崩溃。我已经隔离(并解决)了 2 个原因。

  1. .NET Core 2.0 crashes fatally when a Debug.Assert fails
  2. The test runner was running out of virtual memory由于在 32 位下运行。

但至少还有一个导致崩溃的问题。我想弄清楚为什么测试运行器在 Visual Studio 2017 中崩溃但在命令行上没有崩溃。

另请注意,在 .NET Framework 上运行时不会发生此特定崩溃,因此建议使用不支持 .NET Core 1.0 或 .NET Core 2.0 的命令行工具(例如 vstest.console。 exe) 没有帮助。

最佳答案

已报告多个与此类似的问题。它似乎是尚未修复的 Entity Framework Core 的错误。这也是 .NET Core 命令行 (CLI) 中的一个问题,该问题已得到修复。

未决问题

SqlLite.FunctionalTests sometimes fail on Ubuntu #8642也有同样的问题,不同的应用程序类型,但同样的问题。 OP 也很难找到错误的踪迹。

The active test run was aborted. Reason: 
null

当前打开的已被标记为已阻止:

Discussed again in triage and decided that we need to get more info from the test runner. Commented on Microsoft/vstest#527 asking for more info. Marking as blocked for now until we get some info from the vstest team.

6 月 22 日休息

有一个The reason why the test run was aborted is not indicated. #527
被标记为重复的:
Show the test which crashed the test run (test explorer) #627

解决方案

This is fixed in latest dev builds of dotnet-cli 2.0.0-preview1-005963. Download it from https://dotnetcli.blob.core.windows.net/dotnet/Sdk/release/2.0.0/dotnet-dev-win-x64.latest.zip.

We have also fixed it for VS. Will update when a build with fix is available.

Note: issue will show for netcoreapp2.0 due to dotnet/cli#6535.

.../ fix is available in VS15.3.0 preview2.

如何获取崩溃日志

除了确保您已启用诊断(我相信您已启用)或在控制台上运行它。

A comment来自 github 问题显示使测试运行崩溃的测试(测试资源管理器)#627

Can you enable --diag:log.txt switch to get more logs and analyze log.txt and log.*.host.txt for more details?

因无复现而关闭

No explanation of aborting test when a static constructor throws exception. #334报告了同样的问题:

The active test run was aborted. Reason:

没有理由。

由于无法重现,已关闭。


解决在主线程上运行 nunit 测试的需要 Running unit tests with a main loop .

关于c# - 如何确定导致 Test Explorer 崩溃的异常?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45954441/

相关文章:

javascript - 使用 ASP.NET WEB 表单在母版页中获取 JavaScript 错误

c# - C++ 和 C# 中的混合数组

c# - 什么是C(COM)中的接口(interface)它和C#中的接口(interface)一样吗

f# - 使用 `` Ticked 方法名称时是否可以参数化 NUnit 测试用例显示名称?

nunit - 测试夹具继承和忽略的基本测试夹具

C# 自定义 ObservableCollection

visual-studio - 在 Visual Studio 团队服务的提要中覆盖 nuget 包

.net - Visual Studio 2012/13 导出模板中缺少 MVC NuGet

c# - 带有 NUnit 的 Microsoft PEX

c# - "cannot implement interface member"接口(interface)和混凝土在不同项目时的错误