套件测试
1.新建com.course.testng.suite包,在包下新建SuiteConfig类、LoginTest类、PayTest类,代码如下:
package com.course.testng.suite;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.BeforeTest;
public class SuiteConfig {
@BeforeSuite
public void beforeSuite() {
System.out.println("before suite运行啦");
}
@AfterSuite
public void afterSuite() {
System.out.println("after suite运行啦");
}
@BeforeTest
public void beforeTest() {
System.out.println("beforeTest");
}
@AfterTest
public void afterTest() {
System.out.println("afterTest");
}
}
package com.course.testng.suite;
import org.testng.annotations.Test;
public class LoginTest {
@Test
public void loginTaoBao() {
System.out.println("淘宝登录成功");
}
}
package com.course.testng.suite;
import org.testng.annotations.Test;
public class PayTest {
@Test
public void paySuccess() {
System.out.println("支付宝支付成功");
}
}
2.在src/main/resources包下新建suite.xml文件,代码如下
<?xml version="1.0" encoding="UTF-8"?>
<suite name="test">
<test name="login">
<classes>
<class name="com.course.testng.suite.SuiteConfig"/>
<class name="com.course.testng.suite.LoginTest"/>
</classes>
</test>
<test name="pay">
<classes>
<class name="com.course.testng.suite.SuiteConfig"/>
<class name="com.course.testng.suite.PayTest"/>
</classes>
</test>
</suite>
点击run运行,查看测试结果