Asp.net核心 - 找不到dotnet测试

时间:2016-09-08 16:46:53

标签: c# asp.net unit-testing asp.net-core xunit

我有一个asp.net核心应用程序,我想对它进行一些x-unit测试。但是,当我运行我的测试时,我得到了

dotnet test
No executable found matching command "dotnet-test-"

如何正确配置x-unit?

Project.json

  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.0.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.0.0-preview2-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.0.0",
    "Microsoft.Extensions.Logging": "1.0.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-rc2-final",
    "xunit": "2.1.0",
    "dotnet-test-xunit": "1.0.0-rc2-build10025"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

1 个答案:

答案 0 :(得分:9)

您忘记了testRunner属性:

{
  "dependencies": {
    ...
    "dotnet-test-xunit": "2.2.0-*",
    "xunit": "2.2.0-*"
  },
  ...
  "testRunner": "xunit"
}