我有一个这样的自定义TestNG记者:
import java.util.List;
import java.util.Map;
import org.testng.IReporter;
import org.testng.ISuite;
import org.testng.ISuiteResult;
import org.testng.ITestContext;
import org.testng.xml.XmlSuite;
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()) {
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());
}
}
}
}
我想将它用于我的JUnit测试。有没有比这更简单的方法?
提前致谢。
答案 0 :(得分:2)
我解决了使用此方法在TestNG下运行Junit测试的问题:http://www.tutorialspoint.com/testng/testng_run_junit_tests.htm