Ricardo Peres
Ricardo Peres

Reputation: 14535

Running NUnit Tests in .NET Core with ReSharper

Is it possible to run NUnit tests with R#, when these tests are in a .NET Core project? I have been unable to do that. If I select the option to produce outputs, then R# cannot find the NUnit assembly.

Upvotes: 5

Views: 2557

Answers (3)

M.Hassan
M.Hassan

Reputation: 11032

In vs 2015.3 with Resharper 2017.2, you can create unit test using NUnit for .Net Core 2.

  • Create .Net Core 2 library
  • Modify .csproj, add nuget libraies:

        <ItemGroup>
            <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
            <PackageReference Include="NUnit" Version="3.8.1" />
            <PackageReference Include="NUnit3TestAdapter" Version="3.8.0" />
          </ItemGroup>
    

For more details read : Nunit docs: .NET Core and .NET Standard

Upvotes: 3

DalSoft
DalSoft

Reputation: 11097

Update December 2016: ReSharper 2016.3 is now available. The xUnit and NUnit test runners will work on ReSharper >= 2016.3

ReSharper Early Access Program 2016.3 EAP now supports running .NET Core Tests from R# and it's Awesome it even runs the tests for each framework.

https://confluence.jetbrains.com/display/ReSharper/ReSharper+2016.3+EAP

enter image description here

Project.json (change as appropriate for your use case)

  {
  "version": "1.0.0-*",

  "testRunner": "nunit",

  "runtimes": {
    "win7-x64": {},
    "win8-x64": {},
    "win10-x64": {}
  },

  "dependencies": {
    "NUnit": "3.4.1",
    "dotnet-test-nunit": "3.4.0-beta-2"
  },

  "frameworks": {
    "net451": {
    },

    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  }
}

Upvotes: 6

Rob Prouse
Rob Prouse

Reputation: 22647

Update: The NUnit team and I have released full .NET Core support, it is a console runner that runs tests at the command line and runs tests within Visual Studio's Test Explorer. See NUnit 3 Tests for .NET Core RC2 and ASP.NET Core RC2 for more info.


Neither R#, nor the NUnit Visual Studio adapter, or even the nunit3-console.exe support .NET Core yet. .NET Core projects currently must be tested using NUnitLite by creating a self-executing test assembly.

The NUnit team is working on a better solution that will hopefully be released in the next few months.

Upvotes: 6

Related Questions