IInvocationExecution

public interface IInvocationExecution

com.android.tradefed.invoker.IInvocationExecution


介面,說明將在叫用期間執行的動作。呼叫 TestInvocation 本身可確保呼叫順序。

摘要

公用方法

default void cleanUpBuilds(IInvocationContext context, IConfiguration config)

執行 build_provider 清理步驟。

default void doCleanUp(IInvocationContext context, IConfiguration config, Throwable exception)

執行 target_preparer 和 multi_target_preparer 的清除步驟。

default void doSetup(TestInformation testInfo, IConfiguration config, ITestLogger logger)

執行 target_preparer 和 multi_target_preparer setUp 步驟。

default void doTeardown(TestInformation testInfo, IConfiguration config, ITestLogger logger, Throwable exception)

執行 target_preparer 和 multi_target_preparer 拆除步驟。

default boolean fetchBuild(TestInformation testInfo, IConfiguration config, IRescheduler rescheduler, ITestInvocationListener listener)

執行調用的 build_provider 步驟。

abstract void reportLogs(ITestDevice device, ITestLogger logger, TestInvocation.Stage stage)

在呼叫的不同階段回報部分裝置記錄。

default void runDevicePostInvocationTearDown(IInvocationContext context, IConfiguration config, Throwable exception)

針對叫用的每個裝置部分,叫用 ITestDevice.postInvocationTearDown(Throwable)

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

default void runTests(TestInformation info, IConfiguration config, ITestInvocationListener listener)

執行測試。

default boolean shardConfig(IConfiguration config, TestInformation testInfo, IRescheduler rescheduler, ITestLogger logger)

嘗試將設定分片為子設定,以便重新排程,在多個資源上平行執行。

公用方法

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

執行 target_preparer 和 multi_target_preparer 的 setUp 步驟。設定測試所需的所有裝置。

參數
testInfo TestInformation:叫用的 TestInformation

config IConfiguration:這次測試執行的 IConfiguration

logger ITestLogger:回報設定失敗記錄的 ITestLogger

擲回
com.android.tradefed.device.DeviceNotAvailableException
com.android.tradefed.targetprep.BuildError
com.android.tradefed.targetprep.TargetSetupError
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:測試執行時擲回的原始例外狀況。

擲回
java.lang.Throwable
Throwable

fetchBuild

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 如果成功下載版本,則為 True,否則為 False。

擲回
com.android.tradefed.build.BuildRetrievalError
com.android.tradefed.device.DeviceNotAvailableException
BuildRetrievalError
DeviceNotAvailableException

reportLogs

public abstract void reportLogs (ITestDevice device, 
                ITestLogger logger, 
                TestInvocation.Stage stage)

在呼叫的不同階段回報部分裝置記錄。例如:logcat。

參數
device ITestDevice:要回報記錄的裝置。

logger 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

擲回
com.android.tradefed.device.DeviceNotAvailableException
com.android.tradefed.targetprep.TargetSetupError
DeviceNotAvailableException
TargetSetupError

runTests

public void runTests (TestInformation info, 
                IConfiguration config, 
                ITestInvocationListener listener)

執行測試。

參數
info TestInformation:用於執行測試的 TestInformation

config IConfiguration:要執行的 IConfiguration

listener ITestInvocationListener:測試結果的 ITestInvocationListener

擲回
java.lang.Throwable
Throwable

shardConfig

public boolean shardConfig (IConfiguration config, 
                TestInformation testInfo, 
                IRescheduler rescheduler, 
                ITestLogger logger)

嘗試將設定分片為子設定,以便重新排程,在多個資源上平行執行。

如果分片數大於 1,系統會設定分片索引並重新排程,為每個分片建立設定。如果未設定分片計數,系統會改用 IShardHelper.shardConfig

參數
config IConfiguration:目前的 IConfiguration

testInfo TestInformationTestInformation,其中包含測試資訊。

rescheduler IReschedulerIRescheduler

logger ITestLogger:用於在分片期間記錄檔案的 ITestLogger

傳回
boolean 如果測試已分片,則為 true。否則傳回 false