The reporter class

There are many open source reporter APIs that can be used to provide reports of TestNG Suite results. For instance, ExtentReports by AventStack has an API that allows users to customize the results of a TestNG Suite run into an HTML report format. This reporting API, like others, is based on the TestNG's IReporter class. To generate a custom report using the IReporter interface, users create a new class that implements IReporter and the generateReport method:

import org.testng.IReporter;

/**
* TestNG_Reporter Class
*
* Note: This report relies on the TestNG Suite XML file structure
*
* @author name
*
*/
public class TestNG_Reporter implements IReporter {
/**
* generateReport - method that generates a TestNG results-based
report
*
* @param xmlSuites - the list of all the XML files
* @param suites - the list of all the suites
* @param outputDir - the output directory to save the report
*/
@Override
public void generateReport(List<XmlSuite> xmlSuites,
List<ISuite> suites,
String outputDir) {

for ( ISuite suite : suites ) {
// the report is entirely customizable from here
// users can pull in results from ISuiteResult and
// ITestResult to output to a file, console
// or use a third-party API for HTML reporting
}
}
}
// TestNG Suite XML File

<?xml version="1.0" encoding="UTF-8"
?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

<suite name="My_Test_Suite" preserve-order="true" verbose="2">

<!-- test reporters -->
<listeners>
<listener class-name="myPath.TestNG_Reporter" />
</listeners>
....

</suite>

The ExtentReports API has a Professional and Community Edition of the reporter API. There is full documentation on how to build the HTML report class, customizing it to include system info, test data, screenshots, stacktrace, log file data, TestNG results, and so on. The report has a very elegant CSS look-and-feel to it, and is fairly straightforward to build into the framework. It can then be included in a Test Suite XML file using the format <listener class-name="myPath.ExtentReporterNG" />.

The ExtentReports documentation is located at http://extentreports.com/docs/versions/3/java/.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.9.115