nunit3-netcore-console.dll 未在我的所有程序集中找到测试

问题描述 投票:0回答:1

我使用 nunit3-netcore-console 3.16.3 和 --explore 来列出每个 C# 测试程序集中的测试。我有大约 96 个程序集。它效果很好,只是其中 7 个没有返回任何测试。

我将不起作用的 csproj 与起作用的非常相似的 csproj 进行了比较,但我看不出任何真正的区别。它们都以 net6 为目标,都使用“Microsoft.NET.Test.Sdk”Version=“17.7.0”、“NUnit”Version=“3.13.3”和“NUnit3TestAdapter”Version=“4.5.0”。 App.config 中没有重定向。该命令如下所示:

dotnet nunit3-netcore-console.dll --noheader --explore Tests.dll

我在 Windows 和 Linux 上都有相同的结果。我不能使用

dotnet test --list-tests
因为我也想使用过滤。当我运行测试时,我收到错误,我不确定如何解决,也不确定它们是否是 --explore 不起作用的原因,因为我在尝试运行列出测试的程序集时遇到这样的错误。如果 --explore 有效,我不一定关心错误,因为我不会以这种方式运行测试。这是一个例子:

Unable to load one or more of the requested types.
Could not load file or assembly 'System.Data.Common, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Reference assemblies should not be loaded for execution.  They can only be loaded in the Reflection-only loader context. (0x80131058)

nunit3-console.exe 3.10.0 也会出现同样的问题。当我使用

dotnet test
运行测试时,它们运行良好,这就是我运行它们的方式。

.net-6.0 nunit-3.0
1个回答
0
投票

解决方案是使用 NUnit3.Console 3.15.4 的 net6.0 文件夹中的 nunit3-console.dll,而不是使用 nunit3-netcore-console.dll,这是 NUnit3TestAdapter 4.5.0 的引擎版本。以前,我在尝试使用 nunit3-netcore-console.dll 之前使用的是 NUnit3.ConsoleRunner 3.15.2。

我能够在这里获得帮助:nunit3-netcore-console.dll 未在我的所有程序集中找到测试

© www.soinside.com 2019 - 2024. All rights reserved.