DEV Community

hiclab
hiclab

Posted on

Create a custom report for RCPTT

RCPTT (RCP Testing Tool) includes a functionality that allows to generate reports in multiple formats based on the results obtained from executing test cases. However, the default reports might be insufficient for our needs but fortunately; RCPTT is flexible because it supports generating custom reports.

In this post, we illustrate the basic steps needed to create a custom report renderer so it can be used in RCPTT whether IDE or Test Runner. We use Maven to configure and build the plugin and other related artifacts. By the way, we use a specific project to build an update site for our plugin.

The full code is available at the following repository rcptt-reporting.

Create a report renderer

RCPTT provides the interface IReportRenderer which is the entry point for report generation. Renderers implementing this interface receive a Report iterable object to iterate over all internal reports generated for a given test execution.

public class XMLCustomReportRenderer implements IReportRenderer {

    @Override
    public IStatus generateReport(IContentFactory factory, String reportName, Iterable<Report> reports) {

        // iterate over reports, process their information and create a file in your preferred format ...
        return Status.OK_STATUS;
    }

    @Override
    public String[] getGeneratedFileNames(String reportName) {
        return new String[] { reportName };
    }
}

To access to the results of executed tests, we have to iterate over a collection of Report objects and retrieve the information as follows:

Iterator<Report> reportIterator = reports.iterator();
while (reportIterator.hasNext()) {
    Report report = reportIterator.next();
    Node item = report.getRoot();
    Q7Info info = (Q7Info) item.getProperties().get(IQ7ReportConstants.ROOT);

    // Q7Info object contains the information of an executed test case
}

Add an extension

Once the report renderer is implemented, we have to add an extension for this plugin to be able to use it. The following entry must be added to plugin.xml.

<extension point="org.eclipse.rcptt.reporting.reportRenderer">
    <reportRenderer
        class="com.hiclab.rcptt.reporting.XMLCustomReportRenderer"
        description="XML Custom Report Renderer"
        extension="xml"
        id="XmlReport"
        name="Xml Custom Report">
    </reportRenderer>
</extension>

The id is needed especially when using Test Runner. For more details, check the description of the argument report in Test Runner documentation.

Top comments (0)