AndroidJUnitTest
public
class
AndroidJUnitTest
extends InstrumentationTest
implements
IRuntimeHintProvider,
IShardableTest,
ITestAnnotationFilterReceiver,
ITestFileFilterReceiver,
ITestFilterReceiver
| java.lang.Object | ||
| ↳ | com.android.tradefed.testtype.InstrumentationTest | |
| ↳ | com.android.tradefed.testtype.AndroidJUnitTest | |
這項測試會在指定裝置上執行檢測設備測試套件,並使用 android.support.test.runner.AndroidJUnitRunner。
摘要
常數 | |
|---|---|
String |
EXCLUDE_COLLECTOR_FILTER_KEY
|
String |
INCLUDE_COLLECTOR_FILTER_KEY
收集器端輔助程式庫的選項。 |
String |
NEW_RUN_LISTENER_ORDER_KEY
檢測設備測試執行器引數,用於在裝置端啟用新的 |
String |
USE_TEST_STORAGE_SERVICE
|
公用建構函式 | |
|---|---|
AndroidJUnitTest()
|
|
公用方法 | |
|---|---|
void
|
addAllExcludeAnnotation(
新增註解的 |
void
|
addAllExcludeFilters(
新增要排除的測試篩選器 |
void
|
addAllIncludeAnnotation(
新增註解的 |
void
|
addAllIncludeFilters(
新增要納入測試的篩選器 |
void
|
addExcludeAnnotation(String excludeAnnotation)
如果測試標示了註解,則會新增註解來排除測試。 |
void
|
addExcludeFilter(String filter)
新增要排除的測試篩選器。 |
void
|
addIncludeAnnotation(String annotation)
新增註解,以便在測試標記時加入測試。 |
void
|
addIncludeFilter(String filter)
新增要納入的測試篩選條件。 |
void
|
clearExcludeAnnotations()
刪除目前追蹤的所有排除註解。 |
void
|
clearExcludeFilters()
刪除目前追蹤的所有排除篩選器。 |
void
|
clearIncludeAnnotations()
刪除目前追蹤的所有 include 註解。 |
void
|
clearIncludeFilters()
刪除目前追蹤的所有包含篩選器。 |
|
getExcludeAnnotations()
傳回要排除的註解目前 |
|
getExcludeFilters()
傳回排除篩選器的目前 |
File
|
getExcludeTestFile()
傳回包含排除測試的檔案。 |
|
getIncludeAnnotations()
傳回要加入的註解目前 |
|
getIncludeFilters()
傳回包含篩選器的目前 |
File
|
getIncludeTestFile()
傳回包含內含測試的檔案。 |
long
|
getRuntimeHint()
以毫秒為單位傳回測試的預期執行時間。 |
boolean
|
isClassOrMethod(String filter)
Return if a string is the name of a Class or a Method. |
boolean
|
isParameterizedTest(String filter)
Return if a string is a parameterized test. |
boolean
|
isRegex(String filter)
Return if a string is a regex for filter. |
void
|
run(TestInformation testInfo, ITestInvocationListener listener)
Runs the tests, and reports result to the listener. |
void
|
setExcludeTestFile(File testFile)
設定排除項目的測試檔案。 |
void
|
setIncludeTestFile(File testFile)
設定包含的測試檔案。 |
|
split(int shardCount)
|
受保護的方法 | |
|---|---|
void
|
setRunnerArgs(IRemoteAndroidTestRunner runner)
|
常數
EXCLUDE_COLLECTOR_FILTER_KEY
public static final String EXCLUDE_COLLECTOR_FILTER_KEY
常數值: "exclude-filter-group"
INCLUDE_COLLECTOR_FILTER_KEY
public static final String INCLUDE_COLLECTOR_FILTER_KEY
收集器端輔助程式庫的選項。
常數值: "include-filter-group"
NEW_RUN_LISTENER_ORDER_KEY
public static final String NEW_RUN_LISTENER_ORDER_KEY
檢測設備測試執行器引數,用於在裝置端啟用新的 RunListener 順序。
常數值: "newRunListenerMode"
USE_TEST_STORAGE_SERVICE
public static final String USE_TEST_STORAGE_SERVICE
常數值: "useTestStorageService"
公用建構函式
AndroidJUnitTest
public AndroidJUnitTest ()
公用方法
addAllExcludeAnnotation
public void addAllExcludeAnnotation (excludeAnnotations)
如果測試標示了註解,則新增要排除的註解 ERROR(/Set)。
| 參數 | |
|---|---|
excludeAnnotations |
|
addAllExcludeFilters
public void addAllExcludeFilters (filters)
新增要排除的測試篩選器 ERROR(/Set)。
| 參數 | |
|---|---|
filters |
|
addAllIncludeAnnotation
public void addAllIncludeAnnotation (annotations)
新增 ERROR(/Set) 註解,以便在測試標示該註解時納入。
| 參數 | |
|---|---|
annotations |
|
addAllIncludeFilters
public void addAllIncludeFilters (filters)
新增要納入測試的篩選器 ERROR(/Set)。
| 參數 | |
|---|---|
filters |
|
addExcludeAnnotation
public void addExcludeAnnotation (String excludeAnnotation)
新增註解,如果測試標示了該註解,就會排除測試。
| 參數 | |
|---|---|
excludeAnnotation |
String |
addExcludeFilter
public void addExcludeFilter (String filter)
新增要排除的測試篩選器。
| 參數 | |
|---|---|
filter |
String |
addIncludeAnnotation
public void addIncludeAnnotation (String annotation)
新增註解,以便在測試標記時加入。
| 參數 | |
|---|---|
annotation |
String |
addIncludeFilter
public void addIncludeFilter (String filter)
新增要納入的測試篩選條件。
| 參數 | |
|---|---|
filter |
String |
clearExcludeAnnotations
public void clearExcludeAnnotations ()
刪除目前追蹤的所有排除註解。
clearExcludeFilters
public void clearExcludeFilters ()
刪除目前追蹤的所有排除篩選器。
clearIncludeAnnotations
public void clearIncludeAnnotations ()
刪除目前追蹤的所有 include 註解。
clearIncludeFilters
public void clearIncludeFilters ()
刪除目前追蹤的所有包含篩選器。
getExcludeTestFile
public File getExcludeTestFile ()
傳回包含排除測試的檔案。
| 傳回 | |
|---|---|
File |
|
getIncludeTestFile
public File getIncludeTestFile ()
傳回包含內含測試的檔案。
| 傳回 | |
|---|---|
File |
|
getRuntimeHint
public long getRuntimeHint ()
以毫秒為單位傳回測試的預期執行時間。這段時間用於平衡分片執行作業的負載
| 傳回 | |
|---|---|
long |
|
isClassOrMethod
public boolean isClassOrMethod (String filter)
判斷字串是否為類別或方法的名稱。
| 參數 | |
|---|---|
filter |
String |
| 傳回 | |
|---|---|
boolean |
|
isParameterizedTest
public boolean isParameterizedTest (String filter)
判斷字串是否為參數化測試。
| 參數 | |
|---|---|
filter |
String |
| 傳回 | |
|---|---|
boolean |
|
isRegex
public boolean isRegex (String filter)
傳回字串是否為篩選器的規則運算式。
| 參數 | |
|---|---|
filter |
String |
| 傳回 | |
|---|---|
boolean |
|
得分
public void run (TestInformation testInfo, ITestInvocationListener listener)
執行測試,並向接聽程式回報結果。
| 參數 | |
|---|---|
testInfo |
TestInformation:包含執行測試的實用資訊的 TestInformation 物件。 |
listener |
ITestInvocationListener:測試結果的 ITestInvocationListener |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
setExcludeTestFile
public void setExcludeTestFile (File testFile)
設定排除項目的測試檔案。無法確保 testFile 存在或為檔案。
| 參數 | |
|---|---|
testFile |
File |
setIncludeTestFile
public void setIncludeTestFile (File testFile)
設定包含的測試檔案。無法確保 testFile 存在或為檔案。
| 參數 | |
|---|---|
testFile |
File |
拆分
publicsplit (int shardCount)
split() 的替代版本,也會提供嘗試執行的 shardCount。這項功能適用於有時無法任意決定的測試執行器。
| 參數 | |
|---|---|
shardCount |
int:嘗試的 Shard 數量。 |
| 傳回 | |
|---|---|
|
要個別執行的子測試集合,或測試目前無法分片時的 null |
受保護的方法
setRunnerArgs
protected void setRunnerArgs (IRemoteAndroidTestRunner runner)
| 參數 | |
|---|---|
runner |
IRemoteAndroidTestRunner |