Generate Reports with Java
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.
Prerequisites
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>.*;
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
AxeConfiguration.configure()
.testSuiteName("<suite-name>")
.outputDirectory("<log-directory-location>");
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.
.logResults(_reportOptions.uiState("<scan-name>"))
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 + " <log-directory-location> <desired-destination> --format <desired-format>";
rt.exec(command);
Troubleshooting
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
- Uploading JSON Accessibility Results to axe Reports describes how to upload your results to axe Reports.
- Obtaining an axe Reports API Key tells how to obtain an API key to begin using axe Reports.
- Creating and Filtering Reports shows how you can create accessibility reports in CSV, XML, or HTML from your JSON accessibility results. You can also filter your output by severity using this tool.
- How JSON Results are Stored on Disk describes the file naming conventions for JSON accessibility results.