調用執行

public class InvocationExecution
extends Object implements IInvocationExecution

java.lang.Object
com.android.tradefed.invoker.InvocationExecution


描述所有調用步驟的類:構建下載、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 清理步驟。

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)

為調用的每個設備部分調用ITestDevice#postInvocationTearDown(Throwable)

void runDevicePreInvocationSetup ( IInvocationContext context, IConfiguration config, ITestLogger logger)

為調用的每個設備部分調用ERROR(ITestDevice#preInvocationSetup(IBuildInfo)/com.android.tradefed.device.ITestDevice#preInvocationSetup(com.android.tradefed.build.IBuildInfo) ITestDevice#preInvocationSetup(IBuildInfo))

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

創建返回要使用的IShardHelper

void customizeDevicePreInvocation ( IConfiguration config, IInvocationContext context)

在 preInvocationSetup 之前給一些自定義設備的機會。

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 清理步驟。設備是否清理。

參數
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 IReschedulerIRescheduler ,用於重新安排調用的一部分以在另一個資源上執行

listener ITestInvocationListener :報告構建下載失敗的ITestInvocation

退貨
boolean如果我們成功下載構建,則為真,否則為假。

投擲
BuildRetrievalError
DeviceNotAvailableException

報告日誌

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)

為調用的每個設備部分調用ERROR(ITestDevice#preInvocationSetup(IBuildInfo)/com.android.tradefed.device.ITestDevice#preInvocationSetup(com.android.tradefed.build.IBuildInfo) ITestDevice#preInvocationSetup(IBuildInfo))

參數
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 IReschedulerIRescheduler

logger ITestLoggerITestLogger用於在分片期間記錄文件。

退貨
boolean如果測試被分片則為真。否則返回false

受保護的方法

收集汽車信息

protected void collectAutoInfo (IConfiguration config, 
                TestInformation info)

自動收集有關被測主設備的一些信息。

參數
config IConfiguration

info TestInformation

投擲
DeviceNotAvailableException

創建ShardHelper

protected IShardHelper createShardHelper ()

創建返回要使用的IShardHelper

退貨
IShardHelper

自定義設備預調用

protected void customizeDevicePreInvocation (IConfiguration config, 
                IInvocationContext context)

在 preInvocationSetup 之前給一些自定義設備的機會。

參數
config IConfiguration :調用的配置。

context IInvocationContext :當前調用上下文。

獲取 Adb 版本

protected String getAdbVersion ()

返回用於調用的 adb 版本。

退貨
String

getLabPreparersToRun

protected  getLabPreparersToRun (IConfiguration config, 
                String deviceName)

檢索要在此設備上運行的實驗室準備者列表。

在沙盒類中覆蓋以限制實驗室準備者在沙盒子類中運行

參數
config IConfiguration

deviceName String

退貨

getTargetPreparersToRun

protected  getTargetPreparersToRun (IConfiguration config, 
                String deviceName)

檢索要在此設備上運行的目標準備程序列表。

在沙盒類中覆蓋以限制實驗室準備者在沙盒子類中運行

參數
config IConfiguration

deviceName String

退貨

logHostAdb

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