Voorbeeld Testklasse

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

In het volgende codefragment zie je een complete voorbeeldtest voor Espresso. Eerst wordt de AxeDevTools bibliotheek geïmporteerd en vervolgens geïnitieerd. Het doorgeven van het informatiedossier aan axe DevTools in het @Before blok maakt verbinding met de weergavehiërarchie mogelijk. In hetzelfde blok wordt een voorbeeld gegeven van hoe je de configuratie kunt aanpassen. Ten slotte wordt er een scan uitgevoerd en worden de resultaten geüpload naar het dashboard. Vind meer details over elk onderdeel van dit fragment in onze documentatie.

class ExampleTest {

    private val axe = AxeDevTools()

    init {
        // Connect using an API key 
        axe.startSession(apiKey = "<DEQUE_APIKEY>",
        projectId = "<DEVHUB_PROJECT_ID>")
        // Include the projectId to post results to axe Developer Hub (recommended)
    }

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