主機測試
public class HostTest
extends Object
implements IDeviceTest , ITestFilterReceiver , ITestAnnotationFilterReceiver , IRemoteTest , ITestCollector , IBuildReceiver , IAbiReceiver , IShardableTest , IRuntimeHintProvider , IConfigurationReceiver
java.lang.Object | |
↳ | com.android.tradefed.testtype.HostTest |
基於 JUnit 主機的測試的測試運行器。如果要運行的測試實現了IDeviceTest
則此運行器將傳遞對設備的引用。
概括
領域 | |
---|---|
public static final String | SET_OPTION_DESC |
public static final String | SET_OPTION_NAME
|
公共構造函數 | |
---|---|
HostTest () |
公共方法 | |
---|---|
void | addAllExcludeAnnotation ( notAnnotations) addAllExcludeAnnotation ( notAnnotations) 添加一個 |
void | addAllExcludeFilters ( filters) addAllExcludeFilters ( filters) 添加要排除的測試的過濾器的 |
void | addAllIncludeAnnotation ( annotations) addAllIncludeAnnotation ( annotations) 添加一個 |
void | addAllIncludeFilters ( filters) addAllIncludeFilters ( filters) 添加要包含哪些測試的過濾器的 |
void | addExcludeAnnotation (String notAnnotation) 添加註釋以排除是否測試是否用它標記。 |
void | addExcludeFilter (String filter) 添加要排除哪些測試的過濾器。 |
void | addIncludeAnnotation (String annotation) 添加一個註釋以包含如果一個測試是否用它標記。 |
void | addIncludeFilter (String filter) 添加要包含哪些測試的過濾器。 |
void | clearExcludeAnnotations () 刪除當前跟踪的所有排除註釋。 |
void | clearExcludeFilters () 刪除當前跟踪的所有排除過濾器。 |
void | clearIncludeAnnotations () 刪除當前跟踪的所有包含註釋。 |
void | clearIncludeFilters () 刪除當前跟踪的所有包含過濾器。 |
int | countTestCases () 返回測試的所有類部分的測試用例數 |
IAbi | getAbi () |
getClassNames () | |
ITestDevice | getDevice () 獲取待測設備。 |
getExcludeAnnotations () 返回要排除的註釋的當前 | |
getExcludeFilters () 返回排除過濾器的當前 | |
getIncludeAnnotations () 返回要包含的註釋的當前 | |
getIncludeFilters () 返回包含過濾器的當前 | |
long | getRuntimeHint () 以毫秒為單位返回測試的預期運行時間。 |
void | run ( TestInformation testInfo, ITestInvocationListener listener) 運行測試,並將結果報告給偵聽器。 |
void | setAbi ( IAbi abi) |
void | setBuild ( IBuildInfo buildInfo) |
void | setCollectTestsOnly (boolean shouldCollectTest) 啟用或禁用測試收集模式 |
void | setConfiguration ( IConfiguration configuration) 注入正在使用的 |
void | setDevice ( ITestDevice device) 注入被測設備。 |
static void | setOptionToLoadedObject (Object testObj, keyValueOptions) setOptionToLoadedObject (Object testObj, keyValueOptions) Device Runners 的幫助程序,用於以與 HostTest 相同的方式從 set-option 設置選項。 |
void | setTestInformation ( TestInformation testInfo) |
split (Integer shardCount, TestInformation testInfo) 我們按測試類或方法按個人劃分。 |
受保護的方法 | |
---|---|
HostTest | createHostTest (Class<?> classObj) 分片時創建 HostTest 實例的助手。 |
IBuildInfo | getBuild () 獲取 HostTest 收到的構建信息。 |
ClassLoader | getClassLoader () 返回默認的類加載器。 |
final | getClasses () |
File | getJarFile (String jarName, TestInformation testInfo) 檢查工件通常位於不同用例的幾個位置以找到我們的 jar。 |
boolean | hasJUnit4Annotation (Class<?> classObj) 幫助確定我們是否正在處理帶有 Junit4 註釋的測試類。 |
Object | loadObject (Class<?> classObj) 加載類對象並設置測試信息(設備、構建)。 |
void | setClassName (String className) 清除然後設置要運行的類名。 |
boolean | shouldTestRun (AnnotatedElement annotatedElement) 檢查具有註釋的元素是否通過過濾器。 |
領域
SET_OPTION_DESC
public static final String SET_OPTION_DESC
SET_OPTION_NAME
public static final String SET_OPTION_NAME
公共構造函數
主機測試
public HostTest ()
公共方法
添加所有排除註釋
public void addAllExcludeAnnotation (notAnnotations)
添加一個ERROR(/Set)
註釋以排除是否測試是否用它標記。
參數 | |
---|---|
notAnnotations |
addAllIncludeAnnotation
public void addAllIncludeAnnotation (annotations)
添加一個ERROR(/Set)
註釋以包含是否測試是否用它標記。
參數 | |
---|---|
annotations |
添加排除註解
public void addExcludeAnnotation (String notAnnotation)
添加註釋以排除是否測試是否用它標記。
參數 | |
---|---|
notAnnotation | 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 ()
刪除當前跟踪的所有包含過濾器。
計數測試用例
public int countTestCases ()
返回測試的所有類部分的測試用例數
退貨 | |
---|---|
int |
獲取類名
publicgetClassNames ()
退貨 | |
---|---|
獲取運行時提示
public long getRuntimeHint ()
以毫秒為單位返回測試的預期運行時間。該時間用於負載平衡分片執行
退貨 | |
---|---|
long |
跑步
public void run (TestInformation testInfo, ITestInvocationListener listener)
運行測試,並將結果報告給偵聽器。
參數 | |
---|---|
testInfo | TestInformation :包含運行測試的有用信息的TestInformation 對象。 |
listener | ITestInvocationListener : 測試結果的ITestInvocationListener |
投擲 | |
---|---|
DeviceNotAvailableException |
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
啟用或禁用測試收集模式
設置配置
public void setConfiguration (IConfiguration configuration)
注入正在使用的IConfiguration
。
參數 | |
---|---|
configuration | IConfiguration |
setOptionToLoadedObject
public static void setOptionToLoadedObject (Object testObj,keyValueOptions)
Device Runners 的幫助程序,用於以與 HostTest 相同的方式從 set-option 設置選項。
參數 | |
---|---|
testObj | Object :將接收選項的對象。 |
keyValueOptions |
分裂
publicsplit (Integer shardCount, TestInformation testInfo)
我們按測試類或方法按個人劃分。
參數 | |
---|---|
shardCount | Integer :嘗試的分片數。 |
testInfo | TestInformation :父TestInformation |
退貨 | |
---|---|
要單獨執行的子測試的集合,如果測試當前不可分片則為null |
受保護的方法
創建主機測試
protected HostTest createHostTest (Class<?> classObj)
分片時創建 HostTest 實例的助手。重寫以從 HostTest 返回任何子項。
參數 | |
---|---|
classObj | Class |
退貨 | |
---|---|
HostTest |
獲取類加載器
protected ClassLoader getClassLoader ()
返回默認的類加載器。
退貨 | |
---|---|
ClassLoader |
獲取類
protected finalgetClasses ()
退貨 | |
---|---|
獲取JarFile
protected File getJarFile (String jarName, TestInformation testInfo)
檢查工件通常位於不同用例的幾個位置以找到我們的 jar。
參數 | |
---|---|
jarName | String |
testInfo | TestInformation |
退貨 | |
---|---|
File |
hasJUnit4註解
protected boolean hasJUnit4Annotation (Class<?> classObj)
幫助確定我們是否正在處理帶有 Junit4 註釋的測試類。
參數 | |
---|---|
classObj | Class |
退貨 | |
---|---|
boolean |
加載對象
protected Object loadObject (Class<?> classObj)
加載類對象並設置測試信息(設備、構建)。
參數 | |
---|---|
classObj | Class |
退貨 | |
---|---|
Object |
設置類名
protected void setClassName (String className)
清除然後設置要運行的類名。
參數 | |
---|---|
className | String |
應該測試運行
protected boolean shouldTestRun (AnnotatedElement annotatedElement)
檢查具有註釋的元素是否通過過濾器。公開進行單元測試。
退貨 | |
---|---|
boolean | 如果不應運行測試,則為 false。 |