在MacOS中在.net核心项目上运行NUnit测试

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

我已经使用.net core和Visual Studio for Mac创建了REST API。

我可以创建一个NUnit lib项目来运行我的测试,并且可以使用Visual Studio运行它们。问题是我无法通过命令行运行测试。

这些是我安装的NuGet软件包:

NuGet packages installed

我尝试了以下命令:

  • $ dotnet test Solution.sln
  • $ dotnet test Solution.Test/Solution.Test.csproj

都返回此:

$ dotnet test -v m
  Determining projects to restore...
  All projects are up-to-date for restore.

有什么方法可以运行这样的测试吗?

而且,我已经注意到我的项目正在使用目标框架.NET Core 3.1,而NUnit项目正在使用.NET Framework 4.7.2。此配置有任何问题吗?

我的目标是使用Github Actions运行测试。

谢谢!

c# macos visual-studio command-line nunit
1个回答
0
投票

很棒!感谢Lex Li的评论,我解决了这个问题。

我所做的修复是:

  1. 已删除测试项目;
  2. 使用:$ dotnet new nunit --framework netcoreapp3.1 -n Solution.Name创建了一个新项目>
  3. 现在所有项目都使用相同的.net核心,并且可以在Visual Studio和命令行中运行测试!

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