Generate Reports with Java
Using the axe DevTools HTML reporter with Java
This guide details adding the axe DevTools reporter to your testing project already leveraging axe DevTools HTML.
Integrating the reporter requires a running axe DevTools HTML testing setup. If you aren't already getting axe DevTools HTML scan results, read the guide on how to set up axe DevTools with Java.
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.
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>");
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.
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
Runtime rt = Runtime.getRuntime(); String command = reporter +" reporter <log-directory-location> --dest /<desired-destination> --format <desired-format>"; rt.exec(command);
- 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.