How to run nunit tests with asp.net 5 projects, especially with ReSharper?

爱⌒轻易说出口 提交于 2019-12-05 10:41:41

DNX tests aren't currently supported by ReSharper. It's a whole new execution model, and hasn't yet been implemented for ReSharper. I'd expect to see support as DNX and asp.net stabilise and near release. Also, I don't believe nunit itself supports running as a DNX test runner - the xunit team have a separate project to plug into DNX: https://github.com/xunit/dnx.xunit

NUnit does not support the DNX core.

Follow this issue to see when nunit adds dnx support. https://github.com/nunit/nunit/issues/575

Looks like NUnit has (partial) support as of v3.0.0-RC http://www.alteridem.net/2015/11/04/testing-net-core-using-nunit-3/

Hopefully, by saying "Especially with ReSharper", you mean that you want to know how to run NUnit tests, and if possible, with ReSharper. That being said, here's how to run NUnit tests against ASP.NET Core (Formerly known as ASP.NET 5) in Visual Studio without needing ReSharper:

  1. Add a new project and choose Console Application (.NET Core). Trying to use class libraries will currently report an error.
  2. Add the latest version of the dotnet-test-nunit NuGet package (Make sure that Include prerelease is checked, or you won't find it in the NuGet feed)
  3. Add the latest version of the NUnit NuGet package.
  4. Edit project.json and add this line: "testRunner": "nunit",

Now you can run your tests by choosing Test - Run - All Tests from the Visual Studio menu.

Your project.json file should look like this:

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "dotnet-test-nunit": "3.4.0-beta-1",
    "ProjectUnderTest": "1.0.0-*",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
    "NUnit": "3.4.1"
  },
  "testRunner": "nunit",

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