TestNG 让你忽略所有的@Test方法:
- 在一个类
- 在特定的包
- 在一个包及其所有子包
使用新的注释@Ignore。
在方法级别使用时,@Ignore注释在功能上等同于@Test(enabled=false);该@Ignore注释具有比个人更高的优先级@Test方法的注释。当@Ignore被放置在一个类上时,该类中的所有测试都将被禁用。
mport org.testng.annotations.Ignore;
import org.testng.annotations.Test;
@Ignore
public class TestcaseSample {
@Test
public void testMethod1() {
}
@Test
public void testMethod2() {
}
}
要忽略特定包中的所有测试,您只需创建package-info.java并向其添加@Ignore注释。这是一个示例:
@Ignore
package com.testng.master;
import org.testng.annotations.Ignore;
这会导致com.testng.master包及其所有子包中的所有@Test方法都被忽略。