use of org.testng.ITestContext in project arrow by NetEase.
the class NeXMLSuiteResultWriter method writeAllToBuffer.
private void writeAllToBuffer(XMLStringBuffer xmlBuffer, ISuiteResult suiteResult) {
xmlBuffer.push(NeXMLReporterConfig.TAG_TEST, getSuiteResultAttributes(suiteResult));
Set<ITestResult> testResults = Sets.newHashSet();
ITestContext testContext = suiteResult.getTestContext();
addAllTestResults(testResults, testContext.getPassedTests());
addAllTestResults(testResults, testContext.getFailedTests());
addAllTestResults(testResults, testContext.getSkippedTests());
addAllTestResults(testResults, testContext.getPassedConfigurations());
addAllTestResults(testResults, testContext.getSkippedConfigurations());
addAllTestResults(testResults, testContext.getFailedConfigurations());
addAllTestResults(testResults, testContext.getFailedButWithinSuccessPercentageTests());
addTestResults(xmlBuffer, testResults);
xmlBuffer.pop();
}
use of org.testng.ITestContext in project arrow by NetEase.
the class NeXMLSuiteResultWriter method getSuiteResultAttributes.
private Properties getSuiteResultAttributes(ISuiteResult suiteResult) {
Properties attributes = new Properties();
ITestContext tc = suiteResult.getTestContext();
attributes.setProperty(NeXMLReporterConfig.ATTR_NAME, tc.getName());
XMLReporter.addDurationAttributes(config, attributes, tc.getStartDate(), tc.getEndDate());
return attributes;
}
use of org.testng.ITestContext in project arrow by NetEase.
the class PowerXMLReport method generateReport.
@Override
public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String outputDirectory) {
if (Utils.isStringEmpty(config.getOutputDirectory())) {
config.setOutputDirectory(outputDirectory);
}
// Calculate passed/failed/skipped
int passed = 0;
int failed = 0;
int skipped = 0;
for (ISuite s : suites) {
for (ISuiteResult sr : s.getResults().values()) {
ITestContext testContext = sr.getTestContext();
passed += testContext.getPassedTests().size();
failed += testContext.getFailedTests().size();
skipped += testContext.getSkippedTests().size();
}
}
rootBuffer = new XMLStringBuffer();
Properties p = new Properties();
p.put("passed", passed);
p.put("failed", failed);
p.put("skipped", skipped);
p.put("total", passed + failed + skipped);
rootBuffer.push(XMLReporterConfig.TAG_TESTNG_RESULTS, p);
writeReporterOutput(rootBuffer);
for (ISuite suite : suites) {
writeSuite(suite.getXmlSuite(), suite);
}
rootBuffer.pop();
Utils.writeUtf8File(config.getOutputDirectory(), FILE_NAME, rootBuffer, null);
}
use of org.testng.ITestContext in project arrow by NetEase.
the class PowerEmailableReporter method generateMethodSummaryReport.
/**
* Creates a table showing the highlights of each test method with links to
* the method details
*/
protected void generateMethodSummaryReport(List<ISuite> suites) {
startResultSummaryTable("methodOverview");
int testIndex = 1;
for (ISuite suite : suites) {
if (suites.size() > 1) {
titleRow(suite.getName(), 5);
}
Map<String, ISuiteResult> r = suite.getResults();
for (ISuiteResult r2 : r.values()) {
ITestContext testContext = r2.getTestContext();
String testName = testContext.getName();
m_testIndex = testIndex;
resultSummary(suite, testContext.getSkippedConfigurations(), testName, "skipped", " (configuration methods)");
resultSummary(suite, testContext.getSkippedTests(), testName, "skipped", "");
resultSummary(suite, testContext.getFailedConfigurations(), testName, "failed", " (configuration methods)");
resultSummary(suite, testContext.getFailedTests(), testName, "failed", "");
resultSummary(suite, testContext.getPassedTests(), testName, "passed", "");
testIndex++;
}
}
m_out.println("</table>");
}
use of org.testng.ITestContext in project arrow by NetEase.
the class PowerEmailableReporter method generateSuiteSummaryReport.
public void generateSuiteSummaryReport(List<ISuite> suites) {
tableStart("testOverview", null);
m_out.print("<tr>");
tableColumnStart("Test");
tableColumnStart("Methods<br/>Passed");
tableColumnStart("Scenarios<br/>Passed");
tableColumnStart("# skipped");
tableColumnStart("# failed");
tableColumnStart("Total<br/>Time");
tableColumnStart("Included<br/>Groups");
tableColumnStart("Excluded<br/>Groups");
m_out.println("</tr>");
NumberFormat formatter = new DecimalFormat("#,##0.0");
int qty_tests = 0;
int qty_pass_m = 0;
int qty_pass_s = 0;
int qty_skip = 0;
int qty_fail = 0;
long time_start = Long.MAX_VALUE;
long time_end = Long.MIN_VALUE;
m_testIndex = 1;
for (ISuite suite : suites) {
if (suites.size() > 1) {
titleRow(suite.getName(), 8);
}
Map<String, ISuiteResult> tests = suite.getResults();
for (ISuiteResult r : tests.values()) {
qty_tests += 1;
ITestContext overview = r.getTestContext();
startSummaryRow(overview.getName());
getAllTestIds(overview, suite);
int q = getMethodSet(overview.getPassedTests(), suite).size();
qty_pass_m += q;
summaryCell(q, Integer.MAX_VALUE);
q = overview.getPassedTests().size();
qty_pass_s += q;
summaryCell(q, Integer.MAX_VALUE);
q = getMethodSet(overview.getSkippedTests(), suite).size();
qty_skip += q;
summaryCell(q, 0);
q = getMethodSet(overview.getFailedTests(), suite).size();
qty_fail += q;
summaryCell(q, 0);
time_start = Math.min(overview.getStartDate().getTime(), time_start);
time_end = Math.max(overview.getEndDate().getTime(), time_end);
summaryCell(formatter.format((overview.getEndDate().getTime() - overview.getStartDate().getTime()) / 1000.) + " seconds", true);
summaryCell(overview.getIncludedGroups());
summaryCell(overview.getExcludedGroups());
m_out.println("</tr>");
m_testIndex++;
}
}
if (qty_tests > 1) {
m_out.println("<tr class=\"total\"><td>Total</td>");
summaryCell(qty_pass_m, Integer.MAX_VALUE);
summaryCell(qty_pass_s, Integer.MAX_VALUE);
summaryCell(qty_skip, 0);
summaryCell(qty_fail, 0);
summaryCell(formatter.format((time_end - time_start) / 1000.) + " seconds", true);
m_out.println("<td colspan=\"2\"> </td></tr>");
}
m_out.println("</table>");
}
Aggregations