Esempio di classe di test

This page is not available in the language you requested. You have been redirected to the English version of the page.
Link to this page copied to clipboard
Not for use with personal data

Nel seguente frammento di codice puoi vedere un test di esempio completo per Espresso. In primo luogo, la AxeDevTools libreria viene importata e quindi inizializzata. Il passaggio del registro delle informazioni per axe DevTools nel @Before il blocco consente la connessione alla gerarchia di visualizzazione. Nello stesso blocco viene fornito un esempio su come personalizzare la configurazione. Infine, viene eseguita una scansione e i risultati vengono caricati sulla dashboard. Per maggiori dettagli su ogni parte di questo frammento, consulta la nostra documentazione.

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()
    }
}