AndroidJUnit測試
public class AndroidJUnitTest
extends InstrumentationTest
implements IRuntimeHintProvider , ITestFileFilterReceiver , ITestFilterReceiver , ITestAnnotationFilterReceiver , IShardableTest
java.lang.Object | ||
↳ | com.android.tradefed.testtype.InstrumentationTest | |
↳ | com.android.tradefed.testtype.AndroidJUnitTest |
使用 android.support.test.runner.AndroidJUnitRunner 在給定裝置上執行儀器測試套件的測試。
概括
領域 | |
---|---|
public static final String | EXCLUDE_COLLECTOR_FILTER_KEY |
public static final String | INCLUDE_COLLECTOR_FILTER_KEY 收集器端幫助程式庫中的選項。 |
public static final String | NEW_RUN_LISTENER_ORDER_KEY 儀器測試運行程序參數用於在設備端啟用新的 |
public static final String | USE_TEST_STORAGE_SERVICE
|
公共構造函數 | |
---|---|
AndroidJUnitTest () |
公共方法 | |
---|---|
void | addAllExcludeAnnotation ( excludeAnnotations) addAllExcludeAnnotation ( excludeAnnotations) 新增 |
void | addAllExcludeFilters ( filters) addAllExcludeFilters ( filters) 新增要排除的測試的過濾器的 |
void | addAllIncludeAnnotation ( annotations) addAllIncludeAnnotation ( annotations) 新增 |
void | addAllIncludeFilters ( filters) addAllIncludeFilters ( filters) 新增要包含的測試的過濾器的 |
void | addExcludeAnnotation (String excludeAnnotation) 添加註釋以排除測試是否用它標記。 |
void | addExcludeFilter (String filter) 新增要排除的測試的過濾器。 |
void | addIncludeAnnotation (String annotation) 添加註釋以包含測試是否用它標記。 |
void | addIncludeFilter (String filter) 新增要包含的測試的過濾器。 |
void | clearExcludeAnnotations () 刪除目前追蹤的所有排除註釋。 |
void | clearExcludeFilters () 刪除目前追蹤的所有排除過濾器。 |
void | clearIncludeAnnotations () 刪除目前追蹤的所有包含註釋。 |
void | clearIncludeFilters () 刪除目前追蹤的所有包含過濾器。 |
getExcludeAnnotations () 傳回要排除的註釋的目前 | |
getExcludeFilters () 傳回排除過濾器的目前 | |
File | getExcludeTestFile () 傳回包含排除的測試的檔案。 |
getIncludeAnnotations () 傳回要包含的註解的目前 | |
getIncludeFilters () 傳回包含篩選器的目前 | |
File | getIncludeTestFile () 傳回包含所包含測試的檔案。 |
long | getRuntimeHint () 傳回測試的預期運行時間(以毫秒為單位)。 |
boolean | isClassOrMethod (String filter) 如果字串是類別或方法的名稱,則傳回。 |
boolean | isRegex (String filter) 傳回字串是否是過濾器的正規表示式。 |
void | run ( TestInformation testInfo, ITestInvocationListener 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
INCLUDE_COLLECTOR_FILTER_KEY
public static final String INCLUDE_COLLECTOR_FILTER_KEY
收集器端幫助程式庫中的選項。
NEW_RUN_LISTENER_ORDER_KEY
public static final String NEW_RUN_LISTENER_ORDER_KEY
儀器測試運行程序參數用於在設備端啟用新的RunListener
順序。
使用_測試_儲存_服務
public static final String USE_TEST_STORAGE_SERVICE
公共構造函數
AndroidJUnit測試
public AndroidJUnitTest ()
公共方法
新增全部排除註釋
public void addAllExcludeAnnotation (excludeAnnotations)
新增ERROR(/Set)
註解以排除測試是否用它標記。
參數 | |
---|---|
excludeAnnotations |
新增排除註釋
public void addExcludeAnnotation (String excludeAnnotation)
添加註釋以排除測試是否用它標記。
參數 | |
---|---|
excludeAnnotation | String |
新增排除過濾器
public void addExcludeFilter (String filter)
新增要排除的測試的過濾器。
參數 | |
---|---|
filter | String |
新增包含註釋
public void addIncludeAnnotation (String annotation)
添加註釋以包含測試是否用它標記。
參數 | |
---|---|
annotation | String |
新增包含過濾器
public void addIncludeFilter (String filter)
新增要包含的測試的過濾器。
參數 | |
---|---|
filter | String |
清除排除註釋
public void clearExcludeAnnotations ()
刪除目前追蹤的所有排除註釋。
清除排除過濾器
public void clearExcludeFilters ()
刪除目前追蹤的所有排除過濾器。
清除包含註釋
public void clearIncludeAnnotations ()
刪除目前追蹤的所有包含註釋。
清除包含過濾器
public void clearIncludeFilters ()
刪除目前追蹤的所有包含過濾器。
取得排除測試文件
public File getExcludeTestFile ()
傳回包含排除的測試的檔案。
退貨 | |
---|---|
File |
取得包含測試文件
public File getIncludeTestFile ()
傳回包含所包含測試的檔案。
退貨 | |
---|---|
File |
取得運行時提示
public long getRuntimeHint ()
傳回測試的預期運行時間(以毫秒為單位)。此時間用於負載平衡分片執行
退貨 | |
---|---|
long |
是類別或方法
public boolean isClassOrMethod (String filter)
如果字串是類別或方法的名稱,則傳回。
參數 | |
---|---|
filter | String |
退貨 | |
---|---|
boolean |
是正規表示式
public boolean isRegex (String filter)
傳回字串是否是過濾器的正規表示式。
參數 | |
---|---|
filter | String |
退貨 | |
---|---|
boolean |
跑步
public void run (TestInformation testInfo, ITestInvocationListener listener)
運行測試,並將結果報告給偵聽器。
參數 | |
---|---|
testInfo | TestInformation : TestInformation 物件包含執行測試的有用資訊。 |
listener | ITestInvocationListener :測試結果的ITestInvocationListener |
投擲 | |
---|---|
DeviceNotAvailableException |
設定排除測試文件
public void setExcludeTestFile (File testFile)
設定排除的測試檔案。不確保 testFile 存在或是一個檔案。
參數 | |
---|---|
testFile | File |
設定包含測試文件
public void setIncludeTestFile (File testFile)
設定包含的測試檔案。不確保 testFile 存在或是一個檔案。
參數 | |
---|---|
testFile | File |
分裂
publicsplit (int shardCount)
split()
的替代版本還提供嘗試運行的 shardCount。這對於某些有時無法隨意決定的測試運行者很有用。
參數 | |
---|---|
shardCount | int :嘗試的分片計數。 |
退貨 | |
---|---|
要單獨執行的子測試的集合,如果測試目前不可分片,則為null |
受保護的方法
設置RunnerArgs
protected void setRunnerArgs (IRemoteAndroidTestRunner runner)
參數 | |
---|---|
runner | IRemoteAndroidTestRunner |