VS 测试资源管理器找不到我的单元测试 (XUnit.Runner) ASP.NET 5

Bla*_*ell 3 c# unit-testing xunit visual-studio asp.net-core

我将 ASP.NET 5 与 XUnit 一起使用,而 Visual Studio 在测试资源管理器中找不到我的测试。

我已经多次重建我的项目以使它们刷新。我的测试资源管理器是空的。

有任何想法吗?

这是我的 project.json 文件:

{
  "version": "1.0.0-*",
  "description": "TestLibrary",
  "authors": [ "brivell" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",

  "dependencies": {
    "AutoFixture": "3.38.1",
    "AutoFixture.AutoMoq": "3.38.1",
    "BusinessLibrary": "1.0.0-*",
    "xunit": "2.1.0",
    "xunit.runner.dnx": "2.1.0-rc1-build204"
  },

  "frameworks": {
    "dnx451": { }
  }
}
Run Code Online (Sandbox Code Playgroud)

这是我的一个测试示例:

[Fact]
public void Traditional()
{
    // Arrange
    var sut = new Calculator();

    // Act
    sut.Subtract(1);

    // Assert
    Assert.True(sut.Value < 0);
}
Run Code Online (Sandbox Code Playgroud)

Ken*_*eth 5

您需要在测试项目中安装 XUnit.Runner.Console 包,以便测试运行程序发现您的测试。

https://www.nuget.org/packages/xunit.runner.console