“dotnet test”没有发现任何测试

Gas*_*0de 7 c# xunit.net .net-core

我有一个项目,我无法运行测试,dotnet test而我的同事可以。我收到的错误消息是

System.IO.FileNotFoundException: No test is available in C:\projects\...\bin\Debug\netcoreapp1.1\Test.AnalyzeFirmwareRollout.dll. Make sure test project has a nuget reference of package "Microsoft.NET.Test.Sdk" and framework version settings are appropriate and try again.
Run Code Online (Sandbox Code Playgroud)

该项目确实引用了 Microsoft.NET.Test.Sdk 并且目标框架是

<TargetFramework>netcoreapp1.1</TargetFramework>
Run Code Online (Sandbox Code Playgroud)

在 csproj 文件中。有什么想法这里可能出什么问题吗?

ric*_*sch 11

要从命令行运行 xUnit 测试,您将需要xunit.runner.console包。

  • 对于不使用 Visual Studio(在我的例子中为 Rider)并添加了 xunit.runner.console 但仍然无法通过“dotnet test”运行测试的人。我注意到我需要 xunit.runner.visualstudio 来进行“dotnet test”来发现我的测试。这是相当违反直觉的,这篇博文给了我提示:https://andrewlock.net/running-tests-with-dotnet-xunit-using-cake/ (11认同)