【问题标题】:Test fails in net6.0 with no info在 net6.0 中测试失败,没有任何信息
【发布时间】:2021-11-03 14:59:28
【问题描述】:

所以我开始在 net 6.0 中使用 Visual Studio 2022 社区预览版编写 xunit 测试。

在第一台 PC 上一切正常。

但是当我在另一台 PC(都是 Windows 10)上设置开发环境并尝试运行测试时,我得到了这个:

========== Starting test run ==========
Testhost process exited with error: . Please check the diagnostic logs for more information.
Testhost process exited with error: . Please check the diagnostic logs for more information.
========== Test run aborted: 0 Tests (0 Passed, 0 Failed, 0 Skipped) run in < 1 ms ==========

没有更多信息。我在哪里可以找到那些“诊断日志”,我在网络上找不到有关它的信息。

我尝试使用“dotnet test”在命令终端中手动运行测试,但我明白了:

  **dotnet test
  Determining projects to restore...
  All projects are up-to-date for restore.
  kis-project-information-core -> D:\Users\Thomas MEDARD\Documents\Apollo\Kis\Booth\Libraries\kis-project-information\sources\binaries\net6.0\kis-project-information-core.dll
  kis-project-information-unit-tests -> D:\Users\Thomas MEDARD\Documents\Apollo\Kis\Booth\Libraries\kis-project-information\sources\binaries\net6.0\kis-project-information-unit-tests.dll
Test run for D:\Users\Thomas MEDARD\Documents\Apollo\Kis\Booth\Libraries\kis-project-information\sources\binaries\net6.0\kis-project-information-unit-tests.dll (.NETCoreApp,Version=v6.0)
Microsoft (R) Test Execution Command Line Tool Version 17.0.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
Testhost process exited with error: . Please check the diagnostic logs for more information.

Test Run Aborted.**

我跑了dotnet test -verbosity:diagnostic --diag:log.txt 来查看详细信息,这就是我得到的

log.txt

log.host.21-11-30_10-19-44_26197_5.txt

所以我看到我的测试被检测到,但是运行它时出了点问题

【问题讨论】:

  • 运行项目正常吗?*
  • 这是一个库项目,所以没有 main 可以运行。但是项目构建正常。
  • 您查看过诊断日志吗?试试dotnet test -verbosity:diagnostic --diag:log.txt
  • 您是否阅读了您发布的日志?他们抱怨缺少一个特定的库。要么添加它,要么更好,首先找出为什么需要它并删除它。 Microsoft.Bcl.Async 仅在 .NET Framework 4.0 项目中使用,以允许它们使用 async/await。自 4.5 以来没有 .NET 项目(绝对没有 .NET Core 项目)需要它,除非他们使用需要它的 very 旧库。在这种情况下,解决方案是升级该库
  • 查看日志中的异常。 Microsoft.Bcl.Async 与运行时无关。这是一个兼容性包,仅用于允许旧的 .NET 4 项目使用async/await。重新安装运行时不会改变任何东西。 project 直接使用了缺少的包,或者因为它使用了另一个需要 Microsoft.Bcl.Async 的库/包

标签: c# xunit .net-6.0


【解决方案1】:

好的,我发现发生了什么。

重新安装后我以为一切正常,但实际上我又发现了同样的问题。

我意识到我在终端上处于管理员模式。当我从非管理员终端运行相同的命令时,我得到了问题的解释。

所以我的问题是访问 dotnet。我想这与将我的源代码存储在与 dotnet 不同的驱动器中有关。

我可以毫无问题地构建但测试需要提升权限仍然很奇怪。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-23
    • 2015-03-14
    • 2020-12-25
    • 2021-12-03
    • 1970-01-01
    • 1970-01-01
    • 2020-11-17
    • 1970-01-01
    相关资源
    最近更新 更多