use of org.testng.reporters.XMLStringBuffer in project arrow by NetEase.
the class NeXMLSuiteResultWriter method writeSuiteResult.
/**
* Writes the specified ISuiteResult in the given XMLStringBuffer. Please
* consider that depending on the settings in the <code>config</code>
* property it might generate an additional XML file with the actual content
* and only reference the file with an <code>url</code> attribute in the
* passed XMLStringBuffer.
*
* @param xmlBuffer
* The XML buffer where to write or reference the suite result
* @param suiteResult
* The <code>ISuiteResult</code> to serialize
*/
public void writeSuiteResult(XMLStringBuffer xmlBuffer, ISuiteResult suiteResult) {
if (NeXMLReporterConfig.FF_LEVEL_SUITE_RESULT != config.getFileFragmentationLevel()) {
writeAllToBuffer(xmlBuffer, suiteResult);
} else {
String parentDir = config.getOutputDirectory() + File.separatorChar + suiteResult.getTestContext().getSuite().getName();
File file = referenceSuiteResult(xmlBuffer, parentDir, suiteResult);
XMLStringBuffer suiteXmlBuffer = new XMLStringBuffer();
writeAllToBuffer(suiteXmlBuffer, suiteResult);
Utils.writeUtf8File(file.getAbsoluteFile().getParent(), file.getName(), suiteXmlBuffer.toXML());
}
}
use of org.testng.reporters.XMLStringBuffer 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.reporters.XMLStringBuffer in project arrow by NetEase.
the class PowerXMLReport method writeSuiteToFile.
private void writeSuiteToFile(File suiteFile, ISuite suite) {
XMLStringBuffer xmlBuffer = new XMLStringBuffer();
writeSuiteToBuffer(xmlBuffer, suite);
File parentDir = suiteFile.getParentFile();
if (parentDir.exists() || suiteFile.getParentFile().mkdirs()) {
Utils.writeFile(parentDir.getAbsolutePath(), FILE_NAME, xmlBuffer.toXML());
}
}
Aggregations