TestNG入门指导——include/exclude中的正则表达式

TestNG中的include/exclude属性支持使用正则表达式,下面让我们一起来学习其用法:新建一个java项目,如下结构


RegularExpClass中增加如下代码:

package test.regularexppackage;
import org.testng.annotations.Test;


public class RegularExpClass {

@Test
public void includeTestFirst(){
System.out.print("First include test method");
}

@Test
public void includeTestSecond(){

System.out.print("Second include test method");
}

@Test
public void excludeTestFirst(){

System.out.println("First exclude test method");
}

@Test
public void excludeTestSecond(){

System.out.println("Second exclude test method");

}


@Test
public void includeMethod(){

System.out.println("Include method");

}

@Test
public void excludeMethod(){

System.out.println("Exclude method");
}
}


excreg-testng.xml中增加如下配置信息 (testNG 中任意字符的表示方法 .*)















increg-testng.xml 中增加如下配置信息















选择对应的xml文件然后右击——run as 【TestNG Suite】检查执行结果

你可能感兴趣的:(TestNG)