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 在指定裝置上執行檢測設備測試套件的測試。
摘要
欄位 | |
---|---|
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(
新增 |
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()
刪除目前追蹤的所有包含註解。 |
void
|
clearIncludeFilters()
刪除目前追蹤的所有包含篩選器。 |
|
getExcludeAnnotations()
傳回要排除的註解的目前 |
|
getExcludeFilters()
傳回排除篩選器的目前 |
File
|
getExcludeTestFile()
傳回包含排除測試的檔案。 |
|
getIncludeAnnotations()
傳回要納入的註解目前的 |
|
getIncludeFilters()
傳回目前的包含篩選器 |
File
|
getIncludeTestFile()
傳回包含內含測試的檔案。 |
long
|
getRuntimeHint()
以毫秒為單位,傳回測試的預期執行時間。 |
boolean
|
isClassOrMethod(String filter)
傳回字串是否為類別或方法的名稱。 |
boolean
|
isParameterizedTest(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
訂單的檢測設備測試執行器引數。
USE_TEST_STORAGE_SERVICE
public static final String USE_TEST_STORAGE_SERVICE
公用建構函式
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 ()
刪除目前追蹤的所有納入註解。
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 |
int :嘗試的分割區數量。 |
傳回 | |
---|---|
|
要個別執行的子測試集合,或如果測試目前無法分割,則為 null |
受保護的方法
setRunnerArgs
protected void setRunnerArgs (IRemoteAndroidTestRunner runner)
參數 | |
---|---|
runner |
IRemoteAndroidTestRunner |