【问题标题】:Can I run all the unit-tests defined in a TestClass from a TestMethod in another class?我可以从另一个类中的测试方法运行测试类中定义的所有单元测试吗?
【发布时间】:2011-08-24 09:41:54
【问题描述】:

我有一个 [TestClass],我有一堆单元测试方法来测试“Process_00”相关任务。

我还有另一个 [TestClass],我有测试方法来测试各种过程,例如:

[TestMethod]
public void TestProcess_00 {....}

[TestMethod]
public void TestProcess_01 {....}

[TestMethod]
public void TestProcess_02 {....}

是否可以在 TestMethod 中的单独 [TestClass] 中运行所有测试,例如:

[TestMethod]
public void TestProcess_00() 
{ 
      Assert.IsTrue( //All the tests in a separete test class pass ); 

}

【问题讨论】:

  • 这样做有什么意义?
  • 您可能需要澄清您使用的是哪个单元测试框架

标签: c# .net unit-testing tdd


【解决方案1】:

我认为你不应该这样做。单元测试的目的是验证单段代码,而不是检查其他单元测试是否成功。您可以通过创建测试列表来指定要运行的测试方法来实现这一点。

【讨论】:

    猜你喜欢
    • 2011-02-10
    • 1970-01-01
    • 2015-09-09
    • 2011-01-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多