Unit testing a .NET Standard 1.6 library

Deadly 提交于 2019-11-30 11:17:53

I currently have a working project using xunit 2.1.0 and dotnet-test-xunit 2.2.0-preview2-build1029.

This is my project.json for the unit test project:

{
  "dependencies": {
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.0"
    },
    "MyProject.Library": {
      "target": "project",
    },
    "xunit": "2.1.0"
  },
  "description": "Unit tests",
  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dotnet"
    }
  },
  "testRunner": "xunit"
}

This works both on the command line (via dotnet test) and in the Visual Studio 2015 Test Explorer.

I think that dotnet-test-xunit is being deprecated, but I'm not sure. All of the above will likely change after project.json goes away, but this works today.

I found the issue posted on xUnit's GitHub page here: https://github.com/xunit/xunit/issues/1032

As Brad Wilson explains, NETStandard libraries must be tested with either a dotnet core library or a full .Net Framework library.

In my case I made my unit test library a full "classic desktop" library and Test Explorer was able to run my tests.

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