サンプルテストクラス
Not for use with personal data
次のコードスニペットでは、Espresso の完全なサンプルテストを見ることができます。まず、 AxeDevTools ライブラリがインポートされ、初期化されます。情報レジストリを axe DevTools に渡すことにより、 @Before ブロックでビュー階層への接続が可能になります。同じブロック内で、設定をカスタマイズする方法の例が1つ示されています。最後にスキャンが実行され、結果がダッシュボードにアップロードされます。このスニペットの各部分についての詳細は、ドキュメントをご覧ください。
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()
}
}