サンプルテストクラス

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

次のコードスニペットでは、Espressoの完全なサンプルテストを見ることができます。まず、AxeDevToolsライブラリがインポートされ、次に初期化されます。情報レジストリを@BeforeブロックでAxe DevToolsに渡すことで、ビュー階層に接続することができます。同じブロック内で、設定をカスタマイズする方法の例が一つ示されています。最後にスキャンが実行され、結果がAxe Developer Hubにアップロードされます。このスニペットの各部分についての詳細は、当社のドキュメントでご確認ください。

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

    @Test
    fun foobar() {
        // Scan the app for accessibility issues and upload to Axe Developer Hub
        axe.scan()?.uploadToDashboard()
        axe.tearDown()
    }

    companion object {
        @JvmStatic
        @AfterClass
        fun afterClass() {
            axe.generateHtmlReportAndSummary("optional_name")
        }
    }
}