Sample Test Class
Not for use with personal data
In the following code snippet, you can see a complete sample test for Espresso. First, the AxeDevTools
library is imported then initialized. Passing the information registry to axe DevTools in the @Before
block allows connection to the view heirarchy. In the same block, one example is given for how to customize the configuration. Finally a scan is run, and results are uploaded to the dashboard. Find more details about each piece of this snippet in our documentation.
class ExampleTest {
private val axe = AxeDevTools()
init {
// Connect using an API key
axe.loginWithApiKey(
"DEQUE_API_KEY"
)
}
@Before
fun setup() {
// Pass the information registry to axe DevTools
axe.setInstrumentation(InstrumentationRegistry.getInstrumentation())
// Optional: Add tags or utilize other customization features here
axe.tagScanAs(setOf("Team A"))
}
@Test
fun foobar() {
// Scan the app for accessibility issues and upload to the dashboard
axe.scan()?.uploadToDashboard()
axe.tearDown()
}
}