【问题标题】:How to Make a test method Not Runnable in Visual Studio Unit Test如何在 Visual Studio 单元测试中使测试方法无法运行
【发布时间】:2013-01-24 13:24:13
【问题描述】:

如何使测试方法无法在 Visual Studio 单元测试中运行? 使用带有 .NET 4.0 的 Visual Studio 2010。

假设我有 10 种测试方法,其中 1 种测试方法由于外部依赖性而无法正常工作。如果我想运行所有 10 个,那么我会在一次测试中出错。

一种解决方案是:不要运行测试。但我需要知道,是否有任何属性或类似的东西,它只是绕过测试并且不会运行。

我尝试使用[WorkItem(1234)] 属性,但测试仍在运行。

非常感谢任何帮助。

【问题讨论】:

  • 删除 testmethod 属性?
  • 是的..这可能是一个解决方案,但看起来不太有希望......不过还是谢谢

标签: c# visual-studio-2010 unit-testing testing


【解决方案1】:

是的,您可以将Ignore 属性添加到要跳过的测试中:

[TestMethod, Ignore]
public void ThisTestWontRun()
{
    // Test code here
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-16
    • 2021-10-09
    • 2014-04-26
    • 2020-06-09
    相关资源
    最近更新 更多