呼叫執行
public class InvocationExecution
extends Object
implements IInvocationExecution
java.lang.Object | |
↳ | com.android.tradefed.invoker.InitationExecution |
描述所有呼叫步驟的類別:建置下載、target_prep、執行測試、清理。可以擴展以覆蓋某些步驟的預設行為。步驟的順序由TestInvocation
驅動。
概括
領域 | |
---|---|
public static final String | ADB_VERSION_KEY |
public static final String | JAVA_CLASSPATH_KEY |
public static final 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 cleanUp 步驟。 |
void | doSetup ( TestInformation testInfo, IConfiguration config, ITestLogger listener) 執行 target_preparer 和 multi_target_preparer 設定步驟。 |
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) 在 preIncationSetup 之前有機會自訂某些設備。 |
String | getAdbVersion () 傳回用於呼叫的 adb 版本。 |
getLabPreparersToRun ( IConfiguration config, String deviceName) 檢索要在此裝置上執行的實驗室準備器清單。 | |
getTargetPreparersToRun ( IConfiguration config, String deviceName) 檢索要在此裝置上執行的目標準備器的清單。 | |
void | logHostAdb ( IConfiguration config, ITestLogger logger) 從 $TMPDIR/adb.$UID.log 收集日誌。 |
Throwable | runPreparersTearDown ( TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception, preparersToRun, trackPreparersMap) runPreparersTearDown ( TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception, preparersToRun, trackPreparersMap) runPreparersTearDown ( TestInformation testInfo, ITestDevice device, String deviceName, int deviceIndex, ITestLogger logger, Throwable exception, preparersToRun, trackPreparersMap) |
void | setTestTag ( IBuildInfo info, IConfiguration config) 處理在建置資訊上設定測試標籤。 |
領域
ADB_VERSION_KEY
public static final String ADB_VERSION_KEY
JAVA_CLASSPATH_KEY
public static final String JAVA_CLASSPATH_KEY
JAVA_VERSION_KEY
public static final String JAVA_VERSION_KEY
公共構造函數
呼叫執行
public InvocationExecution ()
公共方法
清理構建
public void cleanUpBuilds (IInvocationContext context, IConfiguration config)
執行 build_provider 清理步驟。與構建獲取相關。
參數 | |
---|---|
context | IInvocationContext :呼叫的IInvocationContext 。 |
config | IConfiguration :本次測試運行的IConfiguration 。 |
清理
public void doCleanUp (IInvocationContext context, IConfiguration config, Throwable exception)
執行 target_preparer 和 multi_target_preparer cleanUp 步驟。設備是否清理乾淨。
參數 | |
---|---|
context | IInvocationContext :呼叫的IInvocationContext 。 |
config | IConfiguration :本次測試運行的IConfiguration 。 |
exception | Throwable :測試運行時拋出的原始異常。 |
執行設定
public void doSetup (TestInformation testInfo, IConfiguration config, ITestLogger listener)
執行 target_preparer 和 multi_target_preparer 設定步驟。是否設定了運行測試所需的所有設備。
參數 | |
---|---|
testInfo | TestInformation :呼叫的TestInformation 。 |
config | IConfiguration :本次測試運行的IConfiguration 。 |
listener | ITestLogger :報告設定失敗日誌的ITestLogger 。 |
投擲 | |
---|---|
BuildError | |
DeviceNotAvailableException | |
TargetSetupError |
拆解
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 :測試運行時拋出的原始異常。 |
獲取構建
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 |
報告日誌
public void reportLogs (ITestDevice device, ITestLogger listener, TestInvocation.Stage stage)
報告調用不同階段的一些設備日誌。例如:logcat。
參數 | |
---|---|
device | ITestDevice :報告日誌的設備。 |
listener | ITestLogger :日誌記錄器。 |
stage | TestInvocation.Stage :我們所處的呼叫階段。 |
runDevicePostInspirationTearDown
public void runDevicePostInvocationTearDown (IInvocationContext context, IConfiguration config, Throwable exception)
為呼叫的每個裝置部分呼叫ITestDevice#postInvocationTearDown(Throwable)
。
參數 | |
---|---|
context | IInvocationContext :呼叫的IInvocationContext 。 |
config | IConfiguration :本次測試運行的IConfiguration 。 |
exception | Throwable :測試運行時拋出的原始異常(如果有)。 |
運行設備預調用設定
public void runDevicePreInvocationSetup (IInvocationContext context, IConfiguration config, ITestLogger logger)
參數 | |
---|---|
context | IInvocationContext :呼叫的IInvocationContext 。 |
config | IConfiguration :本次測試運行的IConfiguration 。 |
logger | ITestLogger :報告日誌的ITestLogger 。 |
投擲 | |
---|---|
DeviceNotAvailableException | |
TargetSetupError |
運行測試
public void runTests (TestInformation info, IConfiguration config, ITestInvocationListener listener)
運行測試。
參數 | |
---|---|
info | TestInformation :用於執行測試的TestInformation 。 |
config | IConfiguration :要運行的IConfiguration |
listener | ITestInvocationListener :測試結果的ITestInvocationListener |
分片配置
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 |
受保護的方法
收集汽車資訊
protected void collectAutoInfo (IConfiguration config, TestInformation info)
自動收集有關被測主設備的一些資訊。
參數 | |
---|---|
config | IConfiguration |
info | TestInformation |
投擲 | |
---|---|
DeviceNotAvailableException |
定制設備預先調用
protected void customizeDevicePreInvocation (IConfiguration config, IInvocationContext context)
在 preIncationSetup 之前有機會自訂某些設備。
參數 | |
---|---|
config | IConfiguration :呼叫的配置。 |
context | IInvocationContext :目前呼叫上下文。 |
取得Adb版本
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 |
退貨 | |
---|---|
日誌主機Adb
protected void logHostAdb (IConfiguration config, ITestLogger logger)
從 $TMPDIR/adb.$UID.log 收集日誌。
參數 | |
---|---|
config | IConfiguration |
logger | ITestLogger |
運行PreparersTearDown
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 |
設定測試標籤
protected void setTestTag (IBuildInfo info, IConfiguration config)
處理在建置資訊上設定測試標籤。
參數 | |
---|---|
info | IBuildInfo |
config | IConfiguration |