Generate Reports with Java

Link to Generate Reports with Java copied to clipboard

Using the axe DevTools for Web reporter with Java

This guide details adding the axe DevTools reporter to your testing project already leveraging axe DevTools for Web.


Integrating the reporter requires a running axe DevTools for Web testing setup. If you aren't already getting axe DevTools for Web scan results, read the guide on how to set up axe DevTools with Java.

You also need to obtain the reporter executable, which can be downloaded from Binary Reporter on the Downloads page. Be sure to see the section Preparing Binaries after Download.

Setting up the Reporter

To use the reporter, it must be imported in its own statement. Replace <binding> with selenium, hamcrest, or cucumber depending on which package you use in your testing setup.

import com.deque.html.axedevtools.<binding>.reporter.*;

Then, a few initialization statements are required. Replace <reporter-binary> with the name of your reporter executable. See Prerequisites above for more information about obtaining the reporter executable. Its name will be OS dependent.

static String reporter = new File("src/test/resources/<reporter-binary>").getAbsolutePath();

Then, initialize your reporting configuration

private AxeReportingOptions _reportOptions = new AxeReportingOptions();

And finally, specify your testing suite name and log file output directory


Writing Tests with the Reporter

While performing scans and writing tests, the logger saves your scan results to file so the reporter can access and compile them. For each scan you want to create a report of, add the .logResults() chain method. Here, you can name your report for future reference.


Generating Reports

Finally, with the reporter configured and results logged, the reporter can access and transform the results. Generally, this step is performed after all scans in a test suite have completed. This code snippet executes the reporter binary. The reporter takes three arguments: the location of the logger's results set up in the AxeConfiguration, the desired destination for the completed report(s), and their desired format. For local testing setups, we recommend selecting html. For CI usage, the xml option produces JUnit xml reports which are compatible with many CI environments. For export to other tools, use csv.

Runtime rt = Runtime.getRuntime();
String command = reporter +" reporter <log-directory-location> --dest /<desired-destination> --format <desired-format>";


If issues with the reporter persist, contact your Deque representative directly, reach us via our support desk, or send us an email. We'll be happy to help.

See Also