HostTest
public
class
HostTest
extends Object
implements
IAbiReceiver,
IBuildReceiver,
IConfigurationReceiver,
IDeviceTest,
IDiscoverTestClasses,
IRemoteTest,
IRuntimeHintProvider,
IShardableTest,
ITestAnnotationFilterReceiver,
ITestCollector,
ITestFilterReceiver
| 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(
新增 |
void
|
addAllExcludeFilters(
新增篩選器的 |
void
|
addAllIncludeAnnotation(
新增註解的 |
void
|
addAllIncludeFilters(
新增篩選器的 |
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,
裝置執行工具的輔助程式,可用於透過 set-option 設定選項,與 HostTest 相同。 |
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 註解的 Test 類別。 |
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
公用建構函式
HostTest
public HostTest ()
公用方法
addAllExcludeAnnotation
public void addAllExcludeAnnotation (notAnnotations)
新增註解的 ERROR(/Set),如果測試標示為註解,則會排除。
| 參數 | |
|---|---|
notAnnotations |
|
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 notAnnotation)
新增註解,用於排除標示為此註解的測試。
| 參數 | |
|---|---|
notAnnotation |
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 ()
刪除目前追蹤的所有包含篩選器。
countTestCases
public int countTestCases ()
傳回測試的所有類別中測試案例的數量
| 傳回 | |
|---|---|
int |
|
getClassNames
publicgetClassNames ()
| 傳回 | |
|---|---|
|
|
getRuntimeHint
public long getRuntimeHint ()
以毫秒為單位,傳回測試的預期執行時間。這段時間用於負載平衡分割執行作業
| 傳回 | |
|---|---|
long |
|
得分
public void run (TestInformation testInfo, ITestInvocationListener listener)
執行測試,並將結果回報給監聽器。
| 參數 | |
|---|---|
testInfo |
TestInformation:包含執行測試所需實用資訊的 TestInformation 物件。 |
listener |
ITestInvocationListener:測試結果的 ITestInvocationListener |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
setCollectTestsOnly
public void setCollectTestsOnly (boolean shouldCollectTest)
啟用或停用測試收集模式
setConfiguration
public void setConfiguration (IConfiguration configuration)
插入正在使用的 IConfiguration。
| 參數 | |
|---|---|
configuration |
IConfiguration |
setDevice
public void setDevice (ITestDevice device)
插入測試中的裝置。
| 參數 | |
|---|---|
device |
ITestDevice:要使用的 ITestDevice |
setOptionToLoadedObject
public static void setOptionToLoadedObject (Object testObj,
keyValueOptions) 裝置執行程式輔助程式,可用於透過 set-option 設定選項,與 HostTest 相同。
| 參數 | |
|---|---|
testObj |
Object:接收選項的物件。 |
keyValueOptions |
:按照 HostTest 設定選項的格式,列出選項清單。 |
setTestInformation
public void setTestInformation (TestInformation testInfo)
| 參數 | |
|---|---|
testInfo |
TestInformation |
拆分
publicsplit (Integer shardCount, TestInformation testInfo)
我們會依測試類別或方法進行個別分割。
| 參數 | |
|---|---|
shardCount |
Integer:嘗試的區塊數量。 |
testInfo |
TestInformation:父項 TestInformation |
| 傳回 | |
|---|---|
|
要個別執行的子測試集合,或如果測試目前無法分割,則為 null |
受保護的方法
createHostTest
protected HostTest createHostTest (Class<?> classObj)
在切割時建立 HostTest 例項的輔助程式。覆寫以便從 HostTest 傳回任何子項。
| 參數 | |
|---|---|
classObj |
Class |
| 傳回 | |
|---|---|
HostTest |
|
getClassLoader
protected ClassLoader getClassLoader ()
傳回預設的類別載入器。
| 傳回 | |
|---|---|
ClassLoader |
|
getClasses
protected finalgetClasses ()
| 傳回 | |
|---|---|
|
|
getJarFile
protected File getJarFile (String jarName,
TestInformation testInfo)檢查幾個通常用於不同用途的建構元素所在位置,找出我們的 JAR 檔案。
| 參數 | |
|---|---|
jarName |
String |
testInfo |
TestInformation |
| 傳回 | |
|---|---|
File |
|
hasJUnit4Annotation
protected boolean hasJUnit4Annotation (Class<?> classObj)
輔助程式,用於判斷是否要處理使用 Junit4 註解的 Test 類別。
| 參數 | |
|---|---|
classObj |
Class |
| 傳回 | |
|---|---|
boolean |
|
loadObject
protected Object loadObject (Class<?> classObj)
載入類別物件並設定測試資訊 (裝置、版本)。
| 參數 | |
|---|---|
classObj |
Class |
| 傳回 | |
|---|---|
Object |
|
setClassName
protected void setClassName (String className)
清除,然後設定要執行的類別名稱。
| 參數 | |
|---|---|
className |
String |
shouldTestRun
protected boolean shouldTestRun (AnnotatedElement annotatedElement)
檢查是否有帶有註解的元素通過篩選。公開供單元測試使用。
| 傳回 | |
|---|---|
boolean |
如果不應執行測試,則為 false。 |