我已经为我的自动化框架生成了使用reportNg的结果报告,但这看起来并不方便,因为它没有显示结果中的测试用例描述。因此,我试图使用生成接口IReporter
定制HTML结果报告,但我发现了以下错误:在使用下面的代码获取“java:incompatible types:java.lang.Object无法转换为org.testng.ISuiteResult”
java: incompatible types: java.lang.Object cannot be converted to org.testng.ISuiteResult
:
import java.util.List;
import java.util.Map;
import org.testng.IReporter;
import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestContext;
public class CustomReporter implements IReporter {
@Override
public void generateReport(List xmlSuites, List suites,
String outputDirectory) {
//Iterating over each suite included in the test
for (ISuite suite : suites) {
//Following code gets the suite name
String suiteName = suite.getName();
//Getting the results for the said suite
Map suiteResults = suite.getResults();
for (ISuiteResult sr : suiteResults.values()) { //issue comes here
ITestContext tc = sr.getTestContext();
System.out.println("Passed tests for suite '" + suiteName +
"' is:" + tc.getPassedTests().getAllResults().size());
System.out.println("Failed tests for suite '" + suiteName +
"' is:" +
tc.getFailedTests().getAllResults().size());
System.out.println("Skipped tests for suite '" + suiteName +
"' is:" +
tc.getSkippedTests().getAllResults().size());
}
}
}
}
*请*把一些时间到格式化你的代码 - 这是非常,非常努力,没有任何indentatio阅读ñ。 –