当我尝试在testng.xml中添加侦听器类时,出现了如下所示的错误消息,如果您能给我一个提示,我将不胜感激。太感谢了! 错误消息:
The content of element type "suite" must match "(groups?,(listeners|packages|test|parameter|method-selectors|suite-files)*)".
testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
<listerners>
<listerner class-name="Academy.listeners"/>
</listerners>
</suite>
侦听器类:
import java.io.IOException;
import org.testng.ITestContext;
import org.testng.ITestListener;
import org.testng.ITestResult;
import resources.DriverBase;
public class listeners implements ITestListener {
DriverBase db = new DriverBase();
public void onTestFailure(ITestResult result) {
// TODO Auto-generated method stub
try {
db.getScreenshot();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
答案 0 :(得分:2)
您的testng xml文件中有一个错字。您将listeners
误写为listerners
请更改
<listerners>
<listerner class-name="Academy.listeners"/>
</listerners>
收件人
<listeners>
<listener class-name="Academy.listeners"/>
</listeners>