Search in sources :

Example 1 with XMLStringBuffer

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());
    }
}
Also used : XMLStringBuffer(org.testng.reporters.XMLStringBuffer) File(java.io.File)

Example 2 with XMLStringBuffer

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);
}
Also used : XMLStringBuffer(org.testng.reporters.XMLStringBuffer) ISuite(org.testng.ISuite) ITestContext(org.testng.ITestContext) ISuiteResult(org.testng.ISuiteResult) Properties(java.util.Properties)

Example 3 with XMLStringBuffer

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());
    }
}
Also used : XMLStringBuffer(org.testng.reporters.XMLStringBuffer) File(java.io.File)

Aggregations

XMLStringBuffer (org.testng.reporters.XMLStringBuffer)3 File (java.io.File)2 Properties (java.util.Properties)1 ISuite (org.testng.ISuite)1 ISuiteResult (org.testng.ISuiteResult)1 ITestContext (org.testng.ITestContext)1