testNG实战03_idea_java_套件测试
创建一个suite的package用来管理下设的类,分别是logintest登录测试,paytest支付测试,suiteconfig,在resources下设一个suite.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!--把写的类和方法都包裹起来,测试标签<test>必须要有名字-->
<suite name = "test">
<test name="login">
<classes>
<class name = "com.ngtest.suite.suiteConfig"/>
<class name = "com.ngtest.suite.loginTest"/>
</classes>
</test>
<test name="pay">
<classes>
<class name ="com.ngtest.suite.suiteConfig"/>
<class name ="com.ngtest.suite.payTest"/>
</classes>
</test>
</suite>
suiteConfig.class
package com.ngtest.suite;
import org.testng.annotations.AfterSuite;
import org.testng.annotations.BeforeSuite;
public class suiteConfig {
//suiteConfig是用来进行所有套件的配置的,在整个测试里都是生效的
//用来写测试套件运行之前的一些共有的东西
@BeforeSuite
public void beforeSuite(){
System.out.println("beforeSuite 运行成功啦");
}
@AfterSuite
public void afterSuite(){
System.out.println("afterSuite 运行成功啦");
}
}
payTest.class
package com.ngtest.suite;
import org.testng.annotations.Test;
public class payTest {
@Test
public void paySuccess(){
System.out.println("支付宝支付成功");
}
}
loginTest.class
package com.ngtest.suite;
import org.testng.annotations.Test;
public class loginTest {
//loginTest是最最重要的逻辑控制的类
//在这里写测试主要的标签方法
@Test
public void loginTaoBao(){
System.out.println("淘宝登陆成功");
}
}
运行suite.xml 结果: