Mobile Application Accessibility Testing: Automating with Espresso and XCTest Frameworks
Why is accessibility testing important?
Last year, Apple CEO Tim Cook expressed the growing need to make all types of applications - web and mobile - accessible to everyone:
“We’ve always viewed accessibility as a human right, and just like human rights are for everyone, we want our products to be accessible to everyone.”
Websites frequently have been targets of disability discrimination and, unfortunately, this trend is making its way into the domain of mobile applications. [see ref]
Leverage instrumented tests (Espresso & XCUITest) for accessibility testing
Espresso users can use their existing tests to run and validate accessibility issues; with a few minor changes, the same test artifacts can help developers find these types of issues early in the process.
The AccessibilityCheck class runs accessibility checks automatically before any interaction with a View. Just import the class and add the following code to your setup methods annotated with @Before:
To learn more about this technique, check out https://developer.android.com/training/testing/espresso/accessibility-checking
iOS developers can take advantage of Google’s GTXiLib, an open-source accessibility test automation framework. GTXiLib is based on the XCTest unit testing framework. You can install GTXiLib for any of your test classes and register a number of accessibility checks to be performed along with your unit tests. If any accessibility check fails, the corresponding unit test will also fail.
To install GTXiLib for one of your test classes, just add the following line of code to its +setup method:
Using this method, all accessibility checks will be run for each of the unit tests defined in that test class.
For more GTXiLib tips and info, take a look at https://github.com/google/GTXiLib
We can make accessibility testing easier
Perfecto has advanced support for Espresso and XCUITests which allows users to combine the power of these test assets with the cloud. Our support for these frameworks enables development teams to retain the advantages discussed above, while adding the security, flexibility, and robustness of Perfecto’s cloud-based platform.
To learn more about the Perfecto solution - https://developers.perfectomobile.com/
Better software can make a difference
Most aspects of mobile accessibility are covered in existing W3C WAI accessibility standards/guidelines. At this time, however, there are no separate guidelines for mobile accessibility; the W3C is developing updated requirements and more specific guidance regarding this important issue.
(reference - https://www.w3.org/WAI/mobile/)
Ensuring a great user experience for everyone doesn’t have to be a chore- the tools we’ve talked about here will help get your testing strategy on the right track. Accessibility is something all companies and developers should be thinking about. It’s just the right thing to do.
As Tim Cook put it:
“We don’t make products for a particular group of people; we make products for everybody. We feel very strongly that everyone deserves an equal opportunity and equal access.”