Search code examples
c#macosvisual-studiocommand-linenunit

Running NUnit tests on .net core project in MacOS


I've created a REST API using .net core and Visual Studio for Mac.

I could create an NUnit lib project to run my tests, and running them using Visual Studio is fine. The problem is that I cannot make the test run through the command line.

These are the NuGet packages I've installed:

NuGet packages installed

I've tryed the following commands:

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

Both returns this:

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

Is there any way to run the tests like this?

Also, I've noticed that my project is using the target framework .NET Core 3.1 and the NUnit project is using .NET Framework 4.7.2. Is there any problem with this config?

My goal is to run the tests using Github Actions.

Thank you!


Solution

  • Awesome! Thanks to Lex Li comment I solved the problem.

    What I did to fix it was:

    1. Deleted the test project;
    2. Created a new project using: $ dotnet new nunit --framework netcoreapp3.1 -n Solution.Name

    Now I have all the projects using the same .net core and I can run the tests in Visual Studio and in the Command-Line!