简体   繁体   English

VS Test Explorer没有找到我的单元测试(XUnit.Runner)ASP.NET 5

[英]VS Test Explorer is not finding my Unit Tests (XUnit.Runner) ASP.NET 5

I am using ASP.NET 5 with XUnit and Visual Studio is not finding my Tests in the test explorer. 我正在使用带有XUnit的ASP.NET 5,而Visual Studio却没有在测试资源管理器中找到我的测试。

I have rebuilt my project several times to get them to refresh. 我已多次重建我的项目以让它们刷新。 My test explorer is empty. 我的测试资源管理器是空的。

Any ideas? 有任何想法吗?

Here is my project.json file: 这是我的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": { }
  }
}

Here is an example of one my my tests: 以下是我的测试中的一个示例:

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

    // Act
    sut.Subtract(1);

    // Assert
    Assert.True(sut.Value < 0);
}

You need to install the package XUnit.Runner.Console in your test project in order for the test runner to discover your tests. 您需要在测试项目中安装包XUnit.Runner.Console,以便测试运行器发现您的测试。

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

With the following 3 XUnit specific properties in project.json , I got Visual Studio's Test Explorer to discover my XUnit tests: 通过project.json的以下3个XUnit特定属性,我获得了Visual Studio的Test Explorer来发现我的XUnit测试:

{
  "version": "1.0.0-*",
  "testRunner": "xunit",
  "dependencies": {
    ...
    "xunit": "2.1.0",
    "dotnet-test-xunit": "2.2.0-preview2-build1029",
    ...
  },
  ...
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 VS 2017 中针对完整的 .net 框架 asp.net 核心项目运行 XUnit 2.2.0 单元测试时出现 System.BadImageFormatException - System.BadImageFormatException when running XUnit 2.2.0 unit test in VS 2017 against a full .net framework asp.net core project VS2017-测试运行程序不接受Xunit测试 - VS2017 - Test runner not picking up Xunit tests 使用xUnit和asp.net核心测试我的服务 - Test my service with xUnit and asp.net core xUnit v1测试出现在xUnit GUI(xunit.gui.clr4.exe)中但不出现在VS 2012 Test Explorer中 - xUnit v1 tests appear in xUnit GUI (xunit.gui.clr4.exe) but not VS 2012 Test Explorer 将xUnit.NET ASP.NET MVC单元测试添加到现有项目/解决方案中 - Adding xUnit.NET ASP.NET MVC unit tests to an existing project/solution 为什么Test Explorer没有看到我对ASP.NET Core MVC的NUnit测试? - Why Test Explorer doesn't see my NUnit tests for ASP.NET Core MVC? ASP.NET Core / EF Core / xUnit.NET 集成测试中每个测试的种子测试数据 - Seed test data for every test in ASP.NET Core / EF Core / xUnit.NET integration tests 如何使用Sqlite对xUnit测试ASP.NET 5 - How to xUnit Test an ASP.NET 5 with Sqlite ASP.NET Core Test xUnit控制器 - ASP.NET Core Test xUnit Controller 如何使用 Xunit 在 ASP.net 中对 [System.Web.Http.Authorize] 过滤器进行单元测试 - How to unit test a [System.Web.Http.Authorize] filter in ASP.net with Xunit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM