【发布时间】: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.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的库/包