Mobile Application Accessibility Testing: Automating with Espresso and XCTest Frameworks

Mobile Application Accessibility Testing: Automating with Espresso and XCTest Frameworks

/, Mobile Application Testing/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.”

~Tim Cook

 

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:

[javascript]
import android.support.test.espresso.contrib.AccessibilityChecks;

@RunWith(AndroidJUnit4.class)

@LargeTest

public class AccessibilityChecksIntegrationTest {

@BeforeClass

public static void enableAccessibilityChecks() {

AccessibilityChecks.enable();

}

}

[/javascript]

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:

[javascript]

+ (void)setUp {

[super setUp];

// ... your other setup code (if any) comes here.

// Install GTX on all tests in *this* test class.

[GTXiLib installOnTestSuite:[GTXTestSuite suiteWithAllTestsInClass:self]

checks:[GTXChecksCollection allGTXChecks]

elementBlacklists:@[]];

}[/javascript]

 

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/display/PD/Test+Frameworks+Support

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.”

Roy has over 15 years of experience in the quality assurance domain, specializing in enterprise software. Over the course of his career, Roy's roles have spanned engineering, product delivery and product management. He is an expert in software quality, application lifecycle management (ALM) and end-to-end IT management. Prior to joining Perfecto, Roy held a number of senior positions at HP Software and Mercury. He holds a B.Sc. in Computer Science from the Hebrew University in Israel.

Leave A Comment