mobile-a11y-test-author
Overview
Native mobile accessibility testing spans two complementary layers:
- Automated audits catch structural issues (missing labels, contrast failures,
undersized tap targets) on every CI run.
- Assistive-technology checks (VoiceOver, TalkBack) verify what automation
cannot observe: announcement order, gesture navigation, hint clarity.
This skill covers both layers on iOS and Android. Full per-platform detail lives in
references/ios-audit.md and
references/android-checks.md.
Nearest neighbors and differentiation:
xcuitest-suite - general XCUITest UI automation; does not cover
performAccessibilityAudit, VoiceOver traits, or touch-target checks.
espresso-suite - general Espresso UI automation; does not wire
AccessibilityChecks, Accessibility Scanner, or TalkBack workflows.
When to use
- An iOS or Android app needs accessibility (a11y) test coverage.
- The team must verify WCAG-aligned requirements (labels, contrast, touch targets,
focus order) on real or simulated devices.
- A screen-reader regression (VoiceOver, TalkBack) has been reported and needs a
test that guards against recurrence.
iOS - core audit
performAccessibilityAudit() (iOS 17+) audits the current view and fails the test
automatically if any issue is found - no explicit assertion needed (wwdc23).
import XCTest
final class HomeAccessibilityTests: XCTestCase {
override func setUpWithError() throws {
continueAfterFailure = true // report ALL issues per screen, not just the first
XCUIApplication().launch()
}
func testHomeScreenAudit() throws {
try XCUIApplication().performAccessibilityAudit()
}
}
Scoped audits, false-positive suppression, audit-per-screen, VoiceOver
label/trait/hint checks, 44pt touch targets, and Accessibility Inspector are in
references/ios-audit.md.
Android - core checks
AccessibilityChecks.enable() fires the Accessibility Test Framework on every
Espresso perform() call; setRunChecksFromRootView(true) checks the whole
hierarchy, not just the interacted view (atf). Requires the
espresso-accessibility dependency.
import androidx.test.espresso.accessibility.AccessibilityChecks
@RunWith(AndroidJUnit4::class)
class CheckoutAccessibilityTest {
init {
AccessibilityChecks.enable().setRunChecksFromRootView(true)
}
@Test
fun applyPromoCode() {
onView(withId(R.id.promo_field)).perform(typeText("WELCOME10"), closeSoftKeyboard())
onView(withId(R.id.apply_button)).perform(click())
// checks fire automatically on every perform()
}
}
The dependency, suppression, 48dp touch targets, contrast thresholds,
contentDescription labelling, and the TalkBack manual workflow are in
references/android-checks.md.
CI integration
iOS (GitHub Actions)
jobs:
a11y-audit:
runs-on: macos-15
steps:
- uses: actions/checkout@v5
- run: |
xcodebuild test \
-project MyApp.xcodeproj \
-scheme MyApp \
-destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \
-only-testing MyAppUITests/HomeAccessibilityTests \
-resultBundlePath A11yResults.xcresult
- uses: actions/upload-artifact@v4
if: always()
with:
name: a11y-xcresult
path: A11yResults.xcresult
Android (GitHub Actions)
jobs:
a11y-checks:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 34
script: ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.CheckoutAccessibilityTest
- uses: actions/upload-artifact@v4
if: always()
with:
name: a11y-test-results
path: app/build/outputs/androidTest-results
Anti-patterns
| Anti-pattern |
Why it fails |
Fix |
continueAfterFailure = false in audit tests |
Stops after the first issue; misses the rest on the same screen |
Set continueAfterFailure = true for audit tests (wwdc23) |
| No suppression closure; globally ignoring an audit type |
Hides all failures of that type, not just the known one |
Suppress by both auditType and element.label (references/ios-audit.md) |
Setting accessibilityLabel to the element type |
"Submit button" - VoiceOver already announces "button" from traits |
Set label to purpose only: "Submit order" (uia) |
contentDescription on every Text composable |
Redundant; TalkBack reads text content automatically |
Omit for plain text; set only for icon-only or image elements (cd) |
Running AccessibilityChecks without setRunChecksFromRootView(true) |
Checks only the interacted view; off-screen violations pass |
Enable root-view mode (Android core, above) (atf) |
| Manual TalkBack only, no automated checks |
Inconsistent; regressions slip in on refactors |
Pair TalkBack manual review with AccessibilityChecks in CI |
Limitations
performAccessibilityAudit requires iOS 17+. For pre-17 targets write
explicit XCUIElement.label and frame assertions (see
references/ios-audit.md).
- Automated audits do not replace assistive-technology testing. The WWDC 2023
session explicitly states they are not a substitute for testing with VoiceOver
or Dynamic Type enabled (wwdc23).
AccessibilityChecks fires on perform() only. Views that are visible but
never interacted with in a given test are not checked unless
setRunChecksFromRootView(true) is set.
- Contrast checks require rendered colors. Dynamic themes or custom draw
code may produce contrast failures only at runtime; static analysis tools
(Android Lint) cannot catch them.
References
- Perform accessibility audits for your app -
performAccessibilityAudit(), audit types, per-screen guidance, continueAfterFailure = true recommendation, suppression closure.
- UIAccessibilityElement -
accessibilityLabel, accessibilityHint, accessibilityTraits.
- Espresso accessibility checking -
AccessibilityChecks.enable(), setRunChecksFromRootView(true), setSuppressingResultMatcher(), per-action firing.
- Describe UI elements -
contentDescription: purpose not visual detail, null for decorative, unique labels in lists.
- Platform detail: references/ios-audit.md, references/android-checks.md.
xcuitest-suite, espresso-suite - functional UI automation; not accessibility-focused.
1---2name: mobile-a11y-test-author3description: "Use when an iOS or Android app needs accessibility tests: XCUITest performAccessibilityAudit (iOS 17+), VoiceOver labels and traits, Espresso AccessibilityChecks, Accessibility Scanner and TalkBack order, plus WCAG checks for labels, 44pt and 48dp touch targets, contrast and focus order."4metadata:5 source: https://skillmd.com/skills/testland/mobile-a11y-test-author6 keywords: "accessibility, a11y, VoiceOver, TalkBack, WCAG, iOS, Android, XCUITest, Espresso, screen reader"7 version: "1.4.10"8---910# mobile-a11y-test-author1112## Overview1314Native mobile accessibility testing spans two complementary layers:1516- **Automated audits** catch structural issues (missing labels, contrast failures,17 undersized tap targets) on every CI run.18- **Assistive-technology checks** (VoiceOver, TalkBack) verify what automation19 cannot observe: announcement order, gesture navigation, hint clarity.2021This skill covers both layers on iOS and Android. Full per-platform detail lives in22[references/ios-audit.md](references/ios-audit.md) and23[references/android-checks.md](references/android-checks.md).2425Nearest neighbors and differentiation:2627- `xcuitest-suite` - general XCUITest UI automation; does not cover28 `performAccessibilityAudit`, VoiceOver traits, or touch-target checks.29- `espresso-suite` - general Espresso UI automation; does not wire30 `AccessibilityChecks`, Accessibility Scanner, or TalkBack workflows.3132## When to use3334- An iOS or Android app needs accessibility (a11y) test coverage.35- The team must verify WCAG-aligned requirements (labels, contrast, touch targets,36 focus order) on real or simulated devices.37- A screen-reader regression (VoiceOver, TalkBack) has been reported and needs a38 test that guards against recurrence.3940---4142## iOS - core audit4344`performAccessibilityAudit()` (iOS 17+) audits the current view and fails the test45automatically if any issue is found - no explicit assertion needed ([wwdc23][wwdc23]).4647```swift48import XCTest4950final class HomeAccessibilityTests: XCTestCase {51 override func setUpWithError() throws {52 continueAfterFailure = true // report ALL issues per screen, not just the first53 XCUIApplication().launch()54 }5556 func testHomeScreenAudit() throws {57 try XCUIApplication().performAccessibilityAudit()58 }59}60```6162Scoped audits, false-positive suppression, audit-per-screen, VoiceOver63label/trait/hint checks, 44pt touch targets, and Accessibility Inspector are in64[references/ios-audit.md](references/ios-audit.md).6566---6768## Android - core checks6970`AccessibilityChecks.enable()` fires the Accessibility Test Framework on every71Espresso `perform()` call; `setRunChecksFromRootView(true)` checks the whole72hierarchy, not just the interacted view ([atf][atf]). Requires the73`espresso-accessibility` dependency.7475```kotlin76import androidx.test.espresso.accessibility.AccessibilityChecks7778@RunWith(AndroidJUnit4::class)79class CheckoutAccessibilityTest {80 init {81 AccessibilityChecks.enable().setRunChecksFromRootView(true)82 }8384 @Test85 fun applyPromoCode() {86 onView(withId(R.id.promo_field)).perform(typeText("WELCOME10"), closeSoftKeyboard())87 onView(withId(R.id.apply_button)).perform(click())88 // checks fire automatically on every perform()89 }90}91```9293The dependency, suppression, 48dp touch targets, contrast thresholds,94`contentDescription` labelling, and the TalkBack manual workflow are in95[references/android-checks.md](references/android-checks.md).9697---9899## CI integration100101### iOS (GitHub Actions)102103```yaml104jobs:105 a11y-audit:106 runs-on: macos-15107 steps:108 - uses: actions/checkout@v5109 - run: |110 xcodebuild test \111 -project MyApp.xcodeproj \112 -scheme MyApp \113 -destination 'platform=iOS Simulator,name=iPhone 15,OS=latest' \114 -only-testing MyAppUITests/HomeAccessibilityTests \115 -resultBundlePath A11yResults.xcresult116 - uses: actions/upload-artifact@v4117 if: always()118 with:119 name: a11y-xcresult120 path: A11yResults.xcresult121```122123### Android (GitHub Actions)124125```yaml126jobs:127 a11y-checks:128 runs-on: ubuntu-latest129 steps:130 - uses: actions/checkout@v5131 - uses: reactivecircus/android-emulator-runner@v2132 with:133 api-level: 34134 script: ./gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.CheckoutAccessibilityTest135 - uses: actions/upload-artifact@v4136 if: always()137 with:138 name: a11y-test-results139 path: app/build/outputs/androidTest-results140```141142---143144## Anti-patterns145146| Anti-pattern | Why it fails | Fix |147|---|---|---|148| `continueAfterFailure = false` in audit tests | Stops after the first issue; misses the rest on the same screen | Set `continueAfterFailure = true` for audit tests ([wwdc23][wwdc23]) |149| No suppression closure; globally ignoring an audit type | Hides all failures of that type, not just the known one | Suppress by both `auditType` and `element.label` ([references/ios-audit.md](references/ios-audit.md)) |150| Setting `accessibilityLabel` to the element type | "Submit button" - VoiceOver already announces "button" from traits | Set label to purpose only: "Submit order" ([uia][uia]) |151| `contentDescription` on every `Text` composable | Redundant; TalkBack reads text content automatically | Omit for plain text; set only for icon-only or image elements ([cd][cd]) |152| Running `AccessibilityChecks` without `setRunChecksFromRootView(true)` | Checks only the interacted view; off-screen violations pass | Enable root-view mode (Android core, above) ([atf][atf]) |153| Manual TalkBack only, no automated checks | Inconsistent; regressions slip in on refactors | Pair TalkBack manual review with `AccessibilityChecks` in CI |154155---156157## Limitations158159- **`performAccessibilityAudit` requires iOS 17+.** For pre-17 targets write160 explicit `XCUIElement.label` and `frame` assertions (see161 [references/ios-audit.md](references/ios-audit.md)).162- **Automated audits do not replace assistive-technology testing.** The WWDC 2023163 session explicitly states they are not a substitute for testing with VoiceOver164 or Dynamic Type enabled ([wwdc23][wwdc23]).165- **`AccessibilityChecks` fires on `perform()` only.** Views that are visible but166 never interacted with in a given test are not checked unless167 `setRunChecksFromRootView(true)` is set.168- **Contrast checks require rendered colors.** Dynamic themes or custom draw169 code may produce contrast failures only at runtime; static analysis tools170 (Android Lint) cannot catch them.171172---173174## References175176- [Perform accessibility audits for your app][wwdc23] - `performAccessibilityAudit()`, audit types, per-screen guidance, `continueAfterFailure = true` recommendation, suppression closure.177- [UIAccessibilityElement][uia] - `accessibilityLabel`, `accessibilityHint`, `accessibilityTraits`.178- [Espresso accessibility checking][atf] - `AccessibilityChecks.enable()`, `setRunChecksFromRootView(true)`, `setSuppressingResultMatcher()`, per-action firing.179- [Describe UI elements][cd] - `contentDescription`: purpose not visual detail, `null` for decorative, unique labels in lists.180- Platform detail: [references/ios-audit.md](references/ios-audit.md), [references/android-checks.md](references/android-checks.md).181- `xcuitest-suite`, `espresso-suite` - functional UI automation; not accessibility-focused.182183[wwdc23]: https://developer.apple.com/videos/play/wwdc2023/10035184[uia]: https://developer.apple.com/documentation/uikit/uiaccessibilityelement185[atf]: https://developer.android.com/training/testing/espresso/accessibility-checking186[cd]: https://developer.android.com/guide/topics/ui/accessibility/apps#describe-ui-element