在.Net Core 1.1中不再发现XUnit测试

TTC*_*TCG 6 c# xunit.net asp.net-core asp.net-core-1.1

我刚刚将我的项目升级到.Net Core 1.1,现在我的所有测试都没有被发现.在旧版本(.Net Core 1.0)中工作正常

以下是XUnit生成的VS 2015输出窗口中的消息

------ Discover test started ------
Discovering tests in 'C:\TW\websites2016\AssetsDB\src\Tests\project.json' ["C:\Program Files\dotnet\dotnet.exe" test "C:\TW\websites2016\AssetsDB\src\Tests\project.json" --output "C:\TW\websites2016\AssetsDB\src\Tests\bin\Debug\netcoreapp1.1" --port 61778 --parentProcessId 7316 --no-build]
'test-xunit' returned '-532462766'.
========== Discover test finished: 0 found (0:00:01.7697049) ==========
Run Code Online (Sandbox Code Playgroud)

project.json中的代码

{
  "version": "1.0.0-*",
  "testRunner": "xunit",

  "dependencies": {
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "AssetsDB": { "target": "project" },
    "xunit": "2.2.0-beta4-build3444",
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
  },

  "frameworks": {
    "netcoreapp1.1": {
      "dependencies": {
        "Microsoft.NETCore.App": {
          "type": "platform",
          "version": "1.1.0"
        }
      },
      "imports": [
        "dotnet5.4",
        "portable-net451+win8"
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我的样品测试:

namespace Tests
{
    public class QueryPagingAssetsTest
    {
        [Fact]
        public void should_return_PagingAssetItems()
        {
             Assert.True(xxxxx);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

有什么我想念的吗?我是否需要更改任何内容以使其与.Net Core 1.1兼容?

更新:project.json的工作版本

您需要添加InternalAbstractions库.如果您按照Brad的链接,它将告诉您使用"xunit.runner.visualstudio"而不是"xunit.runner.visualstudio".但AFAIK,它还没有工作(截至09/12/2016)

"dependencies": {
    "AssetsDB": { "target": "project" },
    "Microsoft.DotNet.InternalAbstractions": "1.0.1-beta-003206",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "xunit": "2.2.0-beta4-build3444",
    "dotnet-test-xunit": "2.2.0-preview2-build1029"
    //"xunit.runner.visualstudio": "2.2.0-beta4-build1194"
  },
Run Code Online (Sandbox Code Playgroud)

Bra*_*son 6

添加"Microsoft.DotNet.InternalAbstractions": "1.0.0"到您的依赖项中,dotnet-test-xunit存在.NET Core 1.1的问题(显然,当新的基于csproj的工具已经用完时,它将被淘汰).查看https://github.com/xunit/xunit/issues/1031#issuecomment-261374279.