Beispiel-Testklasse
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. Die Übergabe des Informationsregisters an axe DevTools im @Before -Block ermöglicht die Verbindung zur Ansichtshierarchie. Im selben Block wird ein Beispiel dafür gegeben, wie die Konfiguration angepasst werden kann. Schließlich wird ein Scan durchgeführt und die Ergebnisse werden an das Dashboard hochgeladen. Weitere Details zu jedem Teil dieses Snippets finden Sie in unserer Dokumentation.
class ExampleTest {
private val axe = AxeDevTools()
init {
// Connect using an API key
axe.startScanSession(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()
}
}