Handle Results
Running a scan returns a ScanResultHandler
, an object containing info about accessibility issues in your app - such as the ID and description of the associated rule and that issue's impact. Review the results and reference our documentation to better understand accessibility rules. In the sample scan, you can see how to use our APIs to handle results within your tests, use them to generate reports, and send them to the Mobile Dashboard for your team to reference.
Using Results
What can you do with results? You can decide what is most useful for your team, but in the following example you can see a few of the possibilities. Get a count of the total number of accessibility failures, or discover the failure counts by severity level. Print a summary of failure counts by rule, and fail tests when critical issues are found.
val scanResultHandler: ScanResultHandler? = axe.scan()
val serializedResult = scanResultHandler?.serializedResult
// Get the failures out of your results
val failures = serializedResult?.axeRuleResults?.filter { axeRuleResult -> axeRuleResult.status == AxeStatus.FAIL }
// Get a count of the total number of accessibility failures.
val failureCount = failures?.size
// Get a failure count by severity level (Minor, Moderate, Serious, Critical)
val criticalFailureCount = failures?.filter { it.impact == AxeImpact.CRITICAL.value }?.size
// Fail the test if critical accessibility failures are found
assertEquals(criticalFailureCount, 0)
// Print a summary of failure counts by rule
serializedResult!!.axeConf!!.rules.forEach { ruleId ->
println(ruleId.key + " failures: " + failures?.filter { it.ruleId == ruleId.key}?.size)
}
// ColorContrast failures: 12