Sys*_*Lol 2 c# xunit xunit.net visual-studio .net-core
我们有一个实用程序项目,Foo.Testing.Common以实际测试项目的帮助程序类命名,名称类似于Foo.Tests.Unit和Foo.Tests.Integration。Common 项目没有测试,只有基类、实用方法等。它引用了 XUnit,所以我可以使用Xunit.Abstractions.
当我们通过 .net 命令行或 VS Test Explorer 运行所有测试时,如何避免看到如下错误?例如,在测试发现期间,VS 测试输出中会出现以下错误。
No test is available in C:\Foo.Testing.Common\bin\Debug\netcoreapp3.1\Foo.Testing.Common.dll. Make sure that test discoverer & executors are registered and platform & framework version settings are appropriate and try again.
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException...
Run Code Online (Sandbox Code Playgroud)
我假设测试过程正在匹配测试以查找测试项目,然后如果其中一个项目没有测试,则会抛出错误。或者也许它正在寻找引用任何 xunit 包的项目?
我们可以重命名该项目,但是有其他方法吗?希望避免将特定测试项目列表传递到命令行,只是为了避免“未找到测试”警告。也就是说,dotnet test应该可以工作。
更新:我也尝试过仅引用xunit.abstractions而xunit.extensibility.core不是主xunit包,但 Common 项目仍然被识别为测试项目。
还尝试IsTestProject在项目属性中设置为 false。
为了跳过,Foo.Testing.Common您可以IsTestProject在 Foo.Testing.Common.csproj 中将属性设置为 false:
<PropertyGroup>
<IsTestProject>false</IsTestProject>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2455 次 |
| 最近记录: |