Beispiel-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

Im folgenden Codeausschnitt sehen Sie einen vollständigen Beispieltest für Espresso. Zuerst wird die AxeDevTools Bibliothek importiert und dann initialisiert. Übergabe des Informationsregisters an Axe DevTools in der @Before block ermöglicht die Verbindung zur Ansichtshierarchie. Im selben Block wird ein Beispiel zur individuellen Anpassung der Konfiguration gegeben. Abschließend wird ein Scan ausgeführt und die Ergebnisse in das Dashboard hochgeladen. Weitere Einzelheiten zu jedem Teil dieses Snippets finden Sie in unserer Dokumentation.

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