AndroidJ單元測試

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

用於在設備端啟用新的RunListener順序的儀器測試運行器參數。

public static final String USE_TEST_STORAGE_SERVICE

公共構造函數

AndroidJUnitTest ()

公共方法

void addAllExcludeAnnotation ( excludeAnnotations) addAllExcludeAnnotation ( excludeAnnotations)

添加一個ERROR(/Set)註釋以排除是否測試是否用它標記。

void addAllExcludeFilters ( filters) addAllExcludeFilters ( filters)

添加要排除的測試的過濾器的ERROR(/Set)

void addAllIncludeAnnotation ( annotations) addAllIncludeAnnotation ( annotations)

添加一個ERROR(/Set)註釋以包含是否測試是否用它標記。

void addAllIncludeFilters ( filters) addAllIncludeFilters ( filters)

添加要包含哪些測試的過濾器的ERROR(/Set)

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

返回要排除的註釋的當前ERROR(/Set)

getExcludeFilters ()

返回排除過濾器的當前ERROR(/Set)

File getExcludeTestFile ()

返回包含排除測試的文件。

getIncludeAnnotations ()

返回要包含的註釋的當前ERROR(/Set)

getIncludeFilters ()

返回包含過濾器的當前ERROR(/Set)

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)

split()的替代版本,它還提供嘗試運行的 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

公共構造函數

AndroidJ單元測試

public AndroidJUnitTest ()

公共方法

添加所有排除註釋

public void addAllExcludeAnnotation ( excludeAnnotations)

添加一個ERROR(/Set)註釋以排除是否測試是否用它標記。

參數
excludeAnnotations

添加所有排除過濾器

public void addAllExcludeFilters ( filters)

添加要排除的測試的過濾器的ERROR(/Set)

參數
filters

addAllIncludeAnnotation

public void addAllIncludeAnnotation ( annotations)

添加一個ERROR(/Set)註釋以包含是否測試是否用它標記。

參數
annotations

添加所有包含過濾器

public void addAllIncludeFilters ( filters)

添加要包含哪些測試的過濾器的ERROR(/Set)

參數
filters

添加排除註解

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

刪除當前跟踪的所有排除過濾器。

clearIncludeAnnotations

public void clearIncludeAnnotations ()

刪除當前跟踪的所有包含註釋。

清除包含過濾器

public void clearIncludeFilters ()

刪除當前跟踪的所有包含過濾器。

getExcludeAnnotations

public  getExcludeAnnotations ()

返回要排除的註釋的當前ERROR(/Set)

退貨

獲取排除過濾器

public  getExcludeFilters ()

返回排除過濾器的當前ERROR(/Set)

退貨

獲取排除測試文件

public File getExcludeTestFile ()

返回包含排除測試的文件。

退貨
File

getIncludeAnnotations

public  getIncludeAnnotations ()

返回要包含的註釋的當前ERROR(/Set)

退貨

getIncludeFilters

public  getIncludeFilters ()

返回包含過濾器的當前ERROR(/Set)

退貨

獲取包含測試文件

public File getIncludeTestFile ()

返回包含包含的測試的文件。

退貨
File

獲取運行時提示

public long getRuntimeHint ()

以毫秒為單位返回測試的預期運行時間。該時間用於負載平衡分片執行

退貨
long

isClassOrMethod

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

分裂

public  split (int shardCount)

split()的替代版本,它還提供嘗試運行的 shardCount。這對於某些有時不能隨意決定的測試運行器很有用。

參數
shardCount int :嘗試的分片數。

退貨
要單獨執行的子測試的集合,如果測試當前不可分片則為null

受保護的方法

setRunnerArgs

protected void setRunnerArgs (IRemoteAndroidTestRunner runner)

參數
runner IRemoteAndroidTestRunner