DEV Community

hiclab
hiclab

Posted on

2 3

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.

Image of Datadog

Master Mobile Monitoring for iOS Apps

Monitor your app’s health with real-time insights into crash-free rates, start times, and more. Optimize performance and prevent user churn by addressing critical issues like app hangs, and ANRs. Learn how to keep your iOS app running smoothly across all devices by downloading this eBook.

Get The eBook

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️