嗨,最好的方法是为西装实现一个监听器类实现 ISuiteListener
基本类如下所示
public class PlatformSuite implements ISuiteListener {
/**
* This method is invoked before the SuiteRunner starts.
*/
public synchronized void onStart(ISuite suite) {
/*Your before suite implementation here*/
}
/**
* This method is invoked after the SuiteRunner has run all
* the test suites.
*/
public void onFinish(ISuite suite) {
/*Your after suite implementation here*/
}
}}
对于 Eclipse 插件,您可以将 testng xmal 指定为“模板 XML 文件”
要在 testng.xml 中启动侦听器,您可以添加以下内容,请记住设置不可用的默认侦听器设置
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
<suite name="DssTestSuite" parallel="false">
<parameter name="useDefaultListeners" value="false"/>
<listeners>
<listener class-name="org.someonr.something.core.PlatformSuite"/>
</listeners>
<test name="sample Test" parallel="false" verbose="2">
<packages>
</packages>
<classes>
</classes>
</test>
此调用将在每个测试套件之前和每个测试套件之后调用