套件测试
//登录成功 loginTest
import org.testng.annotations.Test;
public class LoginTest {
@Test
public void login(){
System.out.println("PMOS登录成功");
}
}
//查询正常 CheckTest
import org.testng.annotations.Test;
public class CheckTest {
@Test
public void check(){
System.out.println("查询正常");
}
}
//套件
import org.testng.annotations.BeforeSuite;
public class SuiteTest {
@BeforeSuite
public void beforeSuite(){
System.out.println("before suite运行了");
}
@AfterSuite
public void afterSuite(){
System.out.println("after suite运行了");
}
}
//配置文件(配置的classes对应的进行先后顺序--SuiteTest类里的内容执行后执行loginTest)
<?xml version="1.0" encoding="UTF-8"?>
<suite name="test">
<test name="login">
<classes>
<class name="com.suite.SuiteTest"></class>
<class name="com.suite.LoginTest"></class>
</classes>
</test>
<test name="check">
<classes>
<class name="com.suite.SuiteTest"></class>
<class name="com.suite.CheckTest"></class>
</classes>
</test>
</suite>
结果(使用suite的配置进行了方法的执行顺序)
before suite运行了
PMOS登录成功
查询正常
after suite运行了
===============================================
test
Total tests run: 2, Failures: 0, Skips: 0
===============================================