.NET(核心)5.0:单元测试永远挂起

hk8txs48  于 2022-11-26  发布在  .NET
关注(0)|答案(2)|浏览(161)

非常简单:无论我使用什么框架(xunit,mstest,nunit),它们都会永远挂起。
输出:

Determining projects to restore...
  All projects are up-to-date for restore.
  testapp -> C:\Users\beene\Documents\coding\csharp\current_projects\testapp\testapp\bin\Debug\net5.0\testapp.dll
  TestProject1 -> C:\Users\beene\Documents\coding\csharp\current_projects\testapp\TestProject1\bin\Debug\net5.0\TestProject1.dll
Test run for C:\Users\beene\Documents\coding\csharp\current_projects\testapp\TestProject1\bin\Debug\net5.0\TestProject1.dll (.NETCoreApp,Version=v5.0)
Microsoft (R) Test Execution Command Line Tool Version 16.11.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
vstest.console process failed to connect to testhost process after 300 seconds. This may occur due to machine slowness, please set environment variable VSTEST_CONNECTION_TIMEOUT to increase timeout.

Test Run Aborted.

重新建置方案不会产生任何类型的警告或错误。重新执行测试会产生相同的问题。
这个项目是一个测试项目,有一个简单的“Hello World!”控制台应用程序和一个简单的函数测试,测试的目的是将一个引用的整数加1。就是这样。这是重现这个问题的最简单的可能安排。
我的研究表明,这些框架实际上确实支持.net 5。我只剩下.NET本身了。
有人遇到过这个问题吗?如果是的话,我将非常感谢一些帮助。
任何需要更多信息或者想运行这些问题的人都可以这样做。我在github上发布了一个基本的测试用例项目,它在我的两台电脑上都重现了这个问题。你可以在这里找到它:https://github.com/BeenEncoded/testproject

bfhwhh0e

bfhwhh0e1#

对于使用WireGuard或MozillaVPN的任何人:它会干扰dotnet连接到vstest.console...
关闭VPN。

46scxncf

46scxncf2#

使用.Net Core,您可以执行以下命令:

dotnet test --blame-hang-timeout 10000

一旦测试挂起超过10秒,它将中断并出现堆栈跟踪

相关问题