如何在TestNG中排除类? [英] How to exclude class in TestNG?
本文介绍了如何在TestNG中排除类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以排除 testng.xml 中的类?
Is this possible to exclude classes in testng.xml?
我试过
<packages>
<package exclude="com.tt.ee"/>
</packages>
但它给出了错误.
推荐答案
根据TestNG dtd,exclude
元素只适用于以下元素:
According to the TestNG dtd, the exclude
element is only applicable to the following elements:
- package - 包列表中的包描述.
- methods - 此测试中包含/排除的方法列表.
- run - 用于定义应运行哪些组的组子标签.
元素classes
和class
不能直接排除;但是,您可以通过组排除类:
The elements classes
and class
cannot be directly excluded; however, you can exclude classes through groups:
@Test(groups = { "ClassTest1" })
public class Test1 {
public void testMethod1() {
}
public void testMethod2() {
}
}
然后你将定义 testng.xml:
Then you will define the testng.xml:
<suite>
<test>
<groups>
<run>
<exclude name="ClassTest1"/>
</run>
</groups>
<classes>
<class name="Test1">
</classes>
</test>
</suite>
在大多数情况下,您可以定义运行要包含的类,而不是要排除的类,因此只需包含要运行的类即可.
In most cases you define, which classes to include for the run, not to exclude, so just include the classes you want to run.
这篇关于如何在TestNG中排除类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文