【问题标题】:Xunit only completing 1 test but there are 6 tests in the projectXunit 仅完成 1 个测试,但项目中有 6 个测试
【发布时间】:2013-04-27 17:52:59
【问题描述】:

我第一次使用 Xunit 编写了 6 个测试。

[Fact] 
public void test_1()...
[Fact] 
public void test_2()...
[Fact] 
public void test_3()...
[Fact] 
public void test_4()...
[Fact] 
public void test_5()...
[Fact] 
public void test_6()...

在这篇帖子Can Visual Studio 2010 Test Runner run XUnit? 之后,我能够将 xunit 控制台添加为 VS 2010 中的外部工具。

但是,当我单击 Xunit Test 菜单项时,我得到以下结果,不应该是 Tests complete : 6 of 6 吗?为什么说 1 of 1?

xUnit.net console test runner (64-bit .NET 4.0.30319.296)
Copyright (C) 2007-11 Microsoft Corporation.

xunit.dll:     Version 1.9.1.1600
Test assembly: C:\Users\...\MyProject-MVC\MyProject.Tests\bin\Debug\MyProject.Tests.dll

Tests complete: 1 of 1
1 total, 0 failed, 0 skipped, took 0.311 seconds

【问题讨论】:

  • 当您在 VS 外部使用 xUnit 控制台/gui 运行程序集时会发生什么?
  • 您是否在运行测试之前构建了解决方案?
  • 我不知道如何在 VS 之外运行 dll。我确实构建了解决方案,构建成功
  • stackoverflow.com/questions/16214684/… ? VS xUnit 插件能找到它们吗?
  • @RubenBartelink 下载 TestDriven.Net 解决了我的问题...我不确定发生了什么,但现在它在说 Tests complete: 6 of 6 谢谢...投票支持您的评论。

标签: c# asp.net-mvc-3 unit-testing tdd xunit.net


【解决方案1】:

@rubenbartelink 的答案是正确的。我的主要测试类是private,换句话说,它不是明确的public

详情:Why is the xUnit Runner not finding my tests

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-11
    • 2021-11-04
    • 1970-01-01
    • 2018-05-27
    • 1970-01-01
    相关资源
    最近更新 更多