如何在TestNG中禁用整个单元测试? [英] How to disable entire unit test in TestNG?
问题描述
这是我在JUnit中可以做的:
This is what I can do in JUnit:
import org.junit.*;
@Ignore
public class FooTest {
//
}
并且将忽略整个班级。我如何在TestNG中做同样的事情?
and the entire class will be ignored. How can I do the same in TestNG?
推荐答案
我相信你想要的是:
@Test(enabled=false)
public class FooTest {
//
}
(您可以将@Test注释应用于类,也可以单独应用于方法。)
(You can apply the @Test annotation to the class, as well as to methods individually.)
TestNG文档包含受支持注释的完整列表,以及描述如果感兴趣,则按组排除/包含测试。以下是相关部分的引用:
The TestNG documentation has a comprehensive list of the supported annotations, and also describes exclusion/inclusion of tests by group if that's of any interest. Here's a quote from the relevant section:
@Test将类或方法标记为
测试的一部分。
@Test Marks a class or a method as part of the test.
...(剪辑)......
启用:此方法是否正确类/方法已启用。
enabled: Whether methods on this class/method are enabled.
编辑:
通过应用<$ c忽略类根据 @Test(enabled = false)在某些版本的TestNG中显然是错误的功能=noreferrer>针对TestNG提出的这个缺陷。
EDIT:
Ignoring a class by applying @Test(enabled=false)
is apparently buggy functionality in some versions of TestNG according to this defect that was raised against TestNG.
这篇关于如何在TestNG中禁用整个单元测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!