TestNG 让你忽略所有的@Test方法:

    • 在一个类
    • 在特定的包
    • 在一个包及其所有子包

    使用新的注释@Ignore。
    在方法级别使用时,@Ignore注释在功能上等同于@Test(enabled=false);该@Ignore注释具有比个人更高的优先级@Test方法的注释。当@Ignore被放置在一个类上时,该类中的所有测试都将被禁用。

    1. mport org.testng.annotations.Ignore;
    2. import org.testng.annotations.Test;
    3. @Ignore
    4. public class TestcaseSample {
    5. @Test
    6. public void testMethod1() {
    7. }
    8. @Test
    9. public void testMethod2() {
    10. }
    11. }

    要忽略特定包中的所有测试,您只需创建package-info.java并向其添加@Ignore注释。这是一个示例:

    1. @Ignore
    2. package com.testng.master;
    3. import org.testng.annotations.Ignore;

    这会导致com.testng.master包及其所有子包中的所有@Test方法都被忽略。