Running NUnit Tests in .NET Core with ReSharper

为君一笑 提交于 2019-12-07 06:45:12

问题


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.


回答1:


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.




回答2:


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

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"
      ]
    }
  }
}



回答3:


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



来源:https://stackoverflow.com/questions/35575110/running-nunit-tests-in-net-core-with-resharper

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!