testng + Ignore 忽略测试方法

时间:2022-11-23 19:02:08

使用testng的时候,有时候会忽略掉某些测试方法,暂时不跑,简单整理一下一些方法.转载还请说明下

1.使用@Test(enable=false)方法

     @Feature("查询")
@Test(description = "验证根据档案号查询功能",enabled = false)
@Parameters({"fileNo", "searchfileNo"})
public void TC_searchByFileNo(String fileNo, String searchfileNo) throws IOException {
employeeInfoListPageActions.modifyMenu();
employeeInfoListPageActions.searchByFileNo(fileNo);
for (int i = 0; i < employeeInfoListPageActions.getSearchData(searchfileNo).size(); i++) {
Assertion.VerityCationString(employeeInfoListPageActions.getSearchData(searchfileNo).get(i), fileNo);
}
}

testng + Ignore 忽略测试方法

2.使用@Ignore方法,此方法针对整个测试类

此方法需要testng版本在6.14.2以上

直接在类上添加该方法

 @Ignore
public class xxx{
}

testng + Ignore 忽略测试方法

3.在testng.xml文件中做操作,添加 enable="false"

testng + Ignore 忽略测试方法

4. 使用exclude方法,忽略单个测试方法

testng + Ignore 忽略测试方法