When customizing your app's semantic properties, for example when following the use cases listed in the semantics guide, verify correctness and prevent regressions by using automated UI tests.
For example, to test that an element's click label is set correctly, use the following code:
@Test fun test() { composeTestRule .onNode(nodeMatcher) .assert( SemanticsMatcher("onClickLabel is set correctly") { it.config.getOrNull(SemanticsActions.OnClick)?.label == "My Click Label" } ) }
Compose testing
For more information on testing in Compose, see the dedicated testing guides.
Additional resources
- Accessibility: Essential concepts and techniques common to all Android app development
- Build Accessible Apps: Key steps you can take to make your app more accessible
- Principles for improving app accessibility: Key principles to keep in mind when working to make your app more accessible
- Testing for Accessibility: Test principles and tools for Android accessibility