InvocationExecution
public
class
InvocationExecution
extends Object
implements
IInvocationExecution
| java.lang.Object | |
| ↳ | com.android.tradefed.invoker.InvocationExecution |
這個類別會說明所有叫用步驟:建構下載、target_prep、執行測試、清除。
可擴充,以覆寫某些步驟的預設行為。步驟順序由 TestInvocation 決定。
摘要
常數 | |
|---|---|
String |
ADB_VERSION_KEY
|
String |
JAVA_CLASSPATH_KEY
|
String |
JAVA_VERSION_KEY
|
公用建構函式 | |
|---|---|
InvocationExecution()
|
|
公用方法 | |
|---|---|
void
|
cleanUpBuilds(IInvocationContext context, IConfiguration config)
執行 build_provider 清除步驟。 |
void
|
doCleanUp(IInvocationContext context, IConfiguration config, Throwable exception)
執行 target_preparer 和 multi_target_preparer 的清除步驟。 |
void
|
doSetup(TestInformation testInfo, IConfiguration config, ITestLogger listener)
執行 target_preparer 和 multi_target_preparer setUp 步驟。 |
void
|
doTeardown(TestInformation testInfo, IConfiguration config, ITestLogger logger, Throwable exception)
執行 target_preparer 和 multi_target_preparer 拆除步驟。 |
boolean
|
fetchBuild(TestInformation testInfo, IConfiguration config, IRescheduler rescheduler, ITestInvocationListener listener)
執行調用的 build_provider 步驟。 |
void
|
reportLogs(ITestDevice device, ITestLogger listener, TestInvocation.Stage stage)
在呼叫的不同階段回報部分裝置記錄。 |
void
|
runDevicePostInvocationTearDown(IInvocationContext context, IConfiguration config, Throwable exception)
針對叫用的每個裝置部分,叫用 |
void
|
runDevicePreInvocationSetup(IInvocationContext context, IConfiguration config, ITestLogger logger)
|
void
|
runTests(TestInformation info, IConfiguration config, ITestInvocationListener listener)
執行測試。 |
boolean
|
shardConfig(IConfiguration config, TestInformation testInfo, IRescheduler rescheduler, ITestLogger logger)
嘗試將設定分片為子設定,以便重新排程,在多個資源上平行執行。 |
受保護的方法 | |
|---|---|
void
|
collectAutoInfo(IConfiguration config, TestInformation info)
自動收集受測主要裝置上的部分資訊。 |
IShardHelper
|
createShardHelper()
建立並傳回要使用的 |
void
|
customizeDevicePreInvocation(IConfiguration config, IInvocationContext context)
執行 preInvocationSetup 前請自訂一些裝置。 |
String
|
getAdbVersion()
傳回用於呼叫的 adb 版本。 |
|
getLabPreparersToRun(IConfiguration config, String deviceName)
擷取要在這部裝置上執行的實驗室準備人員清單。 |
|
getTargetPreparersToRun(IConfiguration config, String deviceName)
擷取要在這部裝置上執行的目標準備人員清單。 |
void
|
linkExternalDirs(IBuildInfo info, TestInformation testInfo)
|
void
|
logHostAdb(IConfiguration config, ITestLogger logger)
從 $TMPDIR/adb.$UID.log 收集記錄。 |
Throwable
|
runPreparersTearDown(TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception,
|
void
|
setTestTag(IBuildInfo info, IConfiguration config)
處理在建構資訊中設定測試標記。 |
常數
ADB_VERSION_KEY
public static final String ADB_VERSION_KEY
常數值: "adb_version"
JAVA_CLASSPATH_KEY
public static final String JAVA_CLASSPATH_KEY
常數值: "java_classpath"
JAVA_VERSION_KEY
public static final String JAVA_VERSION_KEY
常數值: "java_version"
公用建構函式
InvocationExecution
public InvocationExecution ()
公用方法
cleanUpBuilds
public void cleanUpBuilds (IInvocationContext context, IConfiguration config)
執行 build_provider 清理步驟。與建構擷取作業相關聯。
| 參數 | |
|---|---|
context |
IInvocationContext:叫用的 IInvocationContext。 |
config |
IConfiguration:這次測試執行的 IConfiguration。 |
doCleanUp
public void doCleanUp (IInvocationContext context, IConfiguration config, Throwable exception)
執行 target_preparer 和 multi_target_preparer 的 cleanUp 步驟。裝置是否會清理。
| 參數 | |
|---|---|
context |
IInvocationContext:叫用的 IInvocationContext。 |
config |
IConfiguration:這次測試執行的 IConfiguration。 |
exception |
Throwable:測試執行時擲回的原始例外狀況。 |
doSetup
public void doSetup (TestInformation testInfo, IConfiguration config, ITestLogger listener)
執行 target_preparer 和 multi_target_preparer 的 setUp 步驟。設定測試所需的所有裝置。
| 參數 | |
|---|---|
testInfo |
TestInformation:叫用的 TestInformation。 |
config |
IConfiguration:這次測試執行的 IConfiguration。 |
listener |
ITestLogger:回報設定失敗記錄的 ITestLogger。 |
| 擲回 | |
|---|---|
BuildError |
|
DeviceNotAvailableException |
|
TargetSetupError |
|
doTeardown
public void doTeardown (TestInformation testInfo, IConfiguration config, ITestLogger logger, Throwable exception)
執行 target_preparer 和 multi_target_preparer 拆除步驟。是否拆除與設定相關聯的裝置。
| 參數 | |
|---|---|
testInfo |
TestInformation:叫用的 TestInformation。 |
config |
IConfiguration:這次測試執行的 IConfiguration。 |
logger |
ITestLogger:ITestLogger,用於回報記錄。 |
exception |
Throwable:測試執行時擲回的原始例外狀況。 |
fetchBuild
public boolean fetchBuild (TestInformation testInfo, IConfiguration config, IRescheduler rescheduler, ITestInvocationListener listener)
執行調用的 build_provider 步驟。
| 參數 | |
|---|---|
testInfo |
TestInformation:叫用的 TestInformation。 |
config |
IConfiguration:這次測試執行的 IConfiguration。 |
rescheduler |
IRescheduler:IRescheduler,用於重新安排在其他資源上執行的呼叫部分 |
listener |
ITestInvocationListener:用於回報建構版本下載失敗的 ITestInvocation。 |
| 傳回 | |
|---|---|
boolean |
如果成功下載建構版本,則為 True,否則為 False。 |
| 擲回 | |
|---|---|
BuildRetrievalError |
|
DeviceNotAvailableException |
|
reportLogs
public void reportLogs (ITestDevice device, ITestLogger listener, TestInvocation.Stage stage)
在呼叫的不同階段回報部分裝置記錄。例如:logcat。
| 參數 | |
|---|---|
device |
ITestDevice:要回報記錄的裝置。 |
listener |
ITestLogger:記錄的記錄器。 |
stage |
TestInvocation.Stage:我們目前處於的叫用階段。 |
runDevicePostInvocationTearDown
public void runDevicePostInvocationTearDown (IInvocationContext context, IConfiguration config, Throwable exception)
針對叫用的每個裝置部分,叫用 ITestDevice.postInvocationTearDown(Throwable)。
| 參數 | |
|---|---|
context |
IInvocationContext:叫用的 IInvocationContext。 |
config |
IConfiguration:這次測試執行的 IConfiguration。 |
exception |
Throwable:測試執行時擲回的原始例外狀況 (如有)。 |
runDevicePreInvocationSetup
public void runDevicePreInvocationSetup (IInvocationContext context, IConfiguration config, ITestLogger logger)
| 參數 | |
|---|---|
context |
IInvocationContext:叫用的 IInvocationContext。 |
config |
IConfiguration:這次測試執行的 IConfiguration。 |
logger |
ITestLogger:ITestLogger,用於回報記錄。 |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
TargetSetupError |
|
runTests
public void runTests (TestInformation info, IConfiguration config, ITestInvocationListener listener)
執行測試。
| 參數 | |
|---|---|
info |
TestInformation:用於執行測試的 TestInformation。 |
config |
IConfiguration:要執行的 IConfiguration |
listener |
ITestInvocationListener:測試結果的 ITestInvocationListener |
shardConfig
public boolean shardConfig (IConfiguration config, TestInformation testInfo, IRescheduler rescheduler, ITestLogger logger)
嘗試將設定分片為子設定,以便重新排程,在多個資源上平行執行。
如果分片數大於 1,系統會設定分片索引並重新排程,為每個分片建立設定。如果未設定分片計數,系統會改用 IShardHelper.shardConfig。
| 參數 | |
|---|---|
config |
IConfiguration:目前的 IConfiguration。 |
testInfo |
TestInformation:TestInformation,其中包含測試資訊。 |
rescheduler |
IRescheduler:IRescheduler。 |
logger |
ITestLogger:用於在分片期間記錄檔案的 ITestLogger。 |
| 傳回 | |
|---|---|
boolean |
如果測試已分片,則為 true。否則傳回 false |
受保護的方法
collectAutoInfo
protected void collectAutoInfo (IConfiguration config, TestInformation info)
自動收集受測主要裝置的部分資訊。
| 參數 | |
|---|---|
config |
IConfiguration |
info |
TestInformation |
| 擲回 | |
|---|---|
DeviceNotAvailableException |
|
createShardHelper
protected IShardHelper createShardHelper ()
建立並傳回要使用的 IShardHelper。
| 傳回 | |
|---|---|
IShardHelper |
|
customizeDevicePreInvocation
protected void customizeDevicePreInvocation (IConfiguration config, IInvocationContext context)
在 preInvocationSetup 之前,提供自訂部分裝置的機會。
| 參數 | |
|---|---|
config |
IConfiguration:呼叫的設定。 |
context |
IInvocationContext:目前的叫用內容。 |
getAdbVersion
protected String getAdbVersion ()
傳回用於叫用的 adb 版本。
| 傳回 | |
|---|---|
String |
|
getLabPreparersToRun
protectedgetLabPreparersToRun (IConfiguration config, String deviceName)
擷取要在這部裝置上執行的實驗室準備人員清單。
在沙箱類別中覆寫,限制實驗室準備人員在沙箱子項中執行作業
| 參數 | |
|---|---|
config |
IConfiguration |
deviceName |
String |
| 傳回 | |
|---|---|
|
|
getTargetPreparersToRun
protectedgetTargetPreparersToRun (IConfiguration config, String deviceName)
擷取要在這部裝置上執行的目標準備人員清單。
在沙箱類別中覆寫,限制實驗室準備人員在沙箱子項中執行作業
| 參數 | |
|---|---|
config |
IConfiguration |
deviceName |
String |
| 傳回 | |
|---|---|
|
|
linkExternalDirs
protected void linkExternalDirs (IBuildInfo info, TestInformation testInfo)
| 參數 | |
|---|---|
info |
IBuildInfo |
testInfo |
TestInformation |
logHostAdb
protected void logHostAdb (IConfiguration config, ITestLogger logger)
從 $TMPDIR/adb.$UID.log 收集記錄。
| 參數 | |
|---|---|
config |
IConfiguration |
logger |
ITestLogger |
runPreparersTearDown
protected Throwable runPreparersTearDown (TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception,preparersToRun, trackPreparersMap)
| 參數 | |
|---|---|
testInfo |
TestInformation |
device |
ITestDevice |
deviceName |
String |
deviceIndex |
int |
logger |
ITestLogger |
exception |
Throwable |
preparersToRun |
|
trackPreparersMap |
|
| 傳回 | |
|---|---|
Throwable |
|
setTestTag
protected void setTestTag (IBuildInfo info, IConfiguration config)
處理在建構資訊中設定測試標記。
| 參數 | |
|---|---|
info |
IBuildInfo |
config |
IConfiguration |