dotnet 测试无法识别 xunit 测试
dotnet test does not recognize xunit tests
I know that this question has been asked multiple times before I raise it again, However I still could not get the answer for dotnet 5.0 and xunit
我尝试了什么。
- 我定义了以下测试
public class IntegrationTests
{
[Theory]
[MemberData(nameof(Tests), MemberType = typeof(IntegrationTests))]
public void Test(IntegrationTest test)
{
Assert.True(test.Expected, test.Actual);
}
}
- Visual Studio 2019 识别所有测试并运行它们没有任何问题
- dotnet 测试命令说
dotnet test <path to>.csproj
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in C:\<path>\bin\Debug\net5.0\<projectname>.dll.
Make sure that test discoverer & executors are registered and platform & framework
version settings are appropriate and try again.
我不是很明白这里的“测试发现者和执行者”是什么意思。
我的 .csproj 文件有以下 nuget 包(因为许多类似的问题都通过添加其中之一得到解决)
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
我当时在 windows 机器上工作,我做了以下让它工作
- 关闭了我所有的 vscode / visual studio 个实例
- 已删除
C:\Users\<username>\.nuget\packages
个文件夹
- 已删除
<projectname>.csproj
中测试运行程序包的引用
它又开始接受测试
I know that this question has been asked multiple times before I raise it again, However I still could not get the answer for dotnet 5.0 and xunit
我尝试了什么。
- 我定义了以下测试
public class IntegrationTests
{
[Theory]
[MemberData(nameof(Tests), MemberType = typeof(IntegrationTests))]
public void Test(IntegrationTest test)
{
Assert.True(test.Expected, test.Actual);
}
}
- Visual Studio 2019 识别所有测试并运行它们没有任何问题
- dotnet 测试命令说
dotnet test <path to>.csproj
Starting test execution, please wait...
A total of 1 test files matched the specified pattern.
No test is available in C:\<path>\bin\Debug\net5.0\<projectname>.dll.
Make sure that test discoverer & executors are registered and platform & framework
version settings are appropriate and try again.
我不是很明白这里的“测试发现者和执行者”是什么意思。
我的 .csproj 文件有以下 nuget 包(因为许多类似的问题都通过添加其中之一得到解决)
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.console" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
我当时在 windows 机器上工作,我做了以下让它工作
- 关闭了我所有的 vscode / visual studio 个实例
- 已删除
C:\Users\<username>\.nuget\packages
个文件夹 - 已删除
<projectname>.csproj
中测试运行程序包的引用
它又开始接受测试