測試應用程式
本節說明各種工具,協助您透過 Android Studio 或指令列建立、設定及執行測試。
如要進一步瞭解測試的基本概念和撰寫測試的方法,請參閱在 Android 上測試應用程式。
執行及設定測試的方式有很多種:
在基本測試需求中,Android Studio 提供多項功能,可協助建立、執行及檢視 IDE 的測試結果。使用 Studio 時,您可以指向並按一下應用程式原始碼中所需程式碼,以建立特定類別或方法並對其進行測試、使用下拉式選單設定多個測試裝置,並與文字矩陣工具視窗互動,以視覺化方式呈現測試結果。如要進一步瞭解如何使用 Android Studio 建立及管理測試,請參閱在 Android Studio 中測試。
如需更精細的控制,可以透過指令列執行測試。指令列測試可讓您以簡單的方式指定特定模組、建構變數或其組合。透過 Android Debug Bridge (ADB) 殼層執行測試,可讓您針對想執行的測試進行自訂。詳情請參閱透過指令列測試。
針對進階測試需求,您可能需要覆寫預設設定、設定 Gradle 選項或重構程式碼,以便將測試分隔在各自的模組中。如要進一步瞭解如何進行特殊用途的測試設定,請參閱進階測試設定一文。
如要測試使用者與應用程式互動時的行為,可以使用 Espresso Test Recorder、應用程式檢索器、Monkey 測試,以及
monkeyrunner 等這類工具。
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2022-05-04 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"缺少我需要的資訊"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"過於複雜/步驟過多"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"過時"
},{
"type": "thumb-down",
"id": "translationIssue",
"label":"翻譯問題"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"示例/程式碼問題"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"其他"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"容易理解"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"確實解決了我的問題"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"其他"
}]