ModuleDefinition

public class ModuleDefinition
extends Object implements ITestCollector

java.lang.Object
   ↳ com.android.tradefed.testtype.suite.ModuleDefinition


測試執行設定的容器。這個類別是準備及執行測試的輔助工具。

摘要

常數

String ISOLATION_COST

String MODULE_ABI

String MODULE_CACHED

如果測試模組結果已快取,這項屬性會設為 true。

String MODULE_CONTROLLER

String MODULE_EXTERNAL_DEPENDENCIES

String MODULE_ID

模組 ID,這個名稱會在 testRunStart 期間用於專屬識別模組。

String MODULE_INVOCATION_ATTRIBUTE_FLAG_OVERRIDES_KEY

String MODULE_ISOLATED

如果模組是在剛準備好的裝置上執行,這項屬性會設為 true。

String MODULE_NAME

模組名稱是與模組相關聯的基本名稱,通常來自模組載入的 Xml TF 設定檔。

String MODULE_PARAMETERIZATION

String MODULE_SKIPPED

如果略過測試模組,這個屬性會設為 true。

String MODULE_TEST_COUNT

String PREPARATION_TIME

String RETRY_FAIL_COUNT

String RETRY_SUCCESS_COUNT

String RETRY_TIME

String SPARSE_MODULE

如果只回報模組層級事件,這個屬性會設為 true。

String TEAR_DOWN_TIME

String TEST_TIME

公用建構函式

ModuleDefinition()
ModuleDefinition(String name, tests, preparersPerDevice, multiPreparers, IConfiguration moduleConfig)

建構函式

ModuleDefinition(String name, tests, preparersPerDevice, suitePreparersPerDevice, multiPreparers, IConfiguration moduleConfig)

建構函式

公用方法

int compareTo(ModuleDefinition moduleDef)

String getId()

傳回不重複的模組名稱。

Integer getIntraModuleShardCount()
Integer getIntraModuleShardIndex()
IConfiguration getModuleConfiguration()
IInvocationContext getModuleInvocationContext()

傳回與模組相關聯的 IInvocationContext

TestInformation getModuleTestInformation()
getRequiredTokens(TestInformation testInfo)
long getRuntimeHint()

傳回執行模組中所有測試的大約時間。

boolean hasModuleFailed()

如果已對模組呼叫 testRunFailure,則傳回 True。

int neededDevices()

傳回預計會執行這項測試的裝置數量。

int numTests()

傳回目前等待執行的 IRemoteTest 數量。

final void reportNotExecuted(ITestInvocationListener listener, String message)

Report completely not executed modules.

final void run(TestInformation moduleInfo, ITestInvocationListener listener, int maxRunLimit)

執行模組中包含的所有 IRemoteTest,並在裝置設定和清除作業前後使用所有準備工具。

final void run(TestInformation moduleInfo, ITestInvocationListener listener)

執行模組中包含的所有 IRemoteTest,並在裝置設定和清除作業前後使用所有準備工具。

Throwable runPreparation(boolean includeSuitePreparers)

執行測試準備作業,包括套件層級準備作業 (如有指定)。

void setBuild(IBuildInfo build)

插入測試期間要使用的 IBuildInfo

void setCollectTestsOnly(boolean collectTestsOnly)

啟用或停用測試收集模式

void setDevice(ITestDevice device)

插入測試期間要使用的 ITestDevice

void setEnableDynamicDownload(boolean enableDynamicDownload)

是否要在模組層級啟用動態下載。

void setIntraModuleInformation(int shardCount, int shardIndex)
void setLogSaver(ILogSaver logSaver)

將叫用記錄儲存器傳遞至模組,以便在必要時使用。

final void setMergeAttemps(boolean mergeAttempts)

設定是否應合併結果。

void setMetricCollectors( collectors)

將模組要使用的 IMetricCollector 清單注入。

void setRecoverVirtualDevice(boolean recoverVirtualDevice)

設定應會復原虛擬裝置。

void setRemoveModuleBuffering(boolean removeModuleBuffering)
void setReportModuleEnd(boolean shouldReportModuleEnd)
void setReportModuleStart(boolean shouldReportModuleStart)
final void setRetryDecision(IRetryDecision decision)

設定用於模組內重試的 IRetryDecision

void setUseModuleResultsForwarder(boolean useModuleResultsForwarder)
boolean shouldRecoverVirtualDevice()

傳回是否應復原虛擬裝置。

String toString()

void transferSuiteLevelOptions(IConfiguration mSuiteConfiguration)

複製幾個套件層級設定

受保護的方法

boolean hasTests()

如果模組的集區中仍有 IRemoteTest 要執行,則傳回 True。

常數

ISOLATION_COST

public static final String ISOLATION_COST

常數值: "ISOLATION_COST"

MODULE_ABI

public static final String MODULE_ABI

常數值: "module-abi"

MODULE_CACHED

public static final String MODULE_CACHED

如果測試模組結果已快取,這項屬性會設為 true。

常數值: "module-cached"

MODULE_CONTROLLER

public static final String MODULE_CONTROLLER

常數值: "module_controller"

MODULE_EXTERNAL_DEPENDENCIES

public static final String MODULE_EXTERNAL_DEPENDENCIES

常數值: "module-external-dependencies"

MODULE_ID

public static final String MODULE_ID

模組 ID,這個名稱會在 testRunStart 期間用於專屬識別模組。通常是 MODULE_ABI + MODULE_NAME 的組合。

常數值: "module-id"

MODULE_INVOCATION_ATTRIBUTE_FLAG_OVERRIDES_KEY

public static final String MODULE_INVOCATION_ATTRIBUTE_FLAG_OVERRIDES_KEY

常數值: "module-flag-overrides"

MODULE_ISOLATED

public static final String MODULE_ISOLATED

如果模組是在新準備的裝置上執行,這項屬性會設為 true。

常數值: "module-isolated"

MODULE_NAME

public static final String MODULE_NAME

模組名稱是與模組相關聯的基本名稱,通常來自模組載入的 Xml TF 設定檔。

常數值: "module-name"

MODULE_PARAMETERIZATION

public static final String MODULE_PARAMETERIZATION

常數值: "module-param"

MODULE_SKIPPED

public static final String MODULE_SKIPPED

如果略過測試模組,這個屬性會設為 true

常數值: "module-skipped"

MODULE_TEST_COUNT

public static final String MODULE_TEST_COUNT

常數值: "MODULE_TEST_COUNT"

PREPARATION_TIME

public static final String PREPARATION_TIME

常數值: "PREP_TIME"

RETRY_FAIL_COUNT

public static final String RETRY_FAIL_COUNT

常數值: "MODULE_RETRY_FAILED"

RETRY_SUCCESS_COUNT

public static final String RETRY_SUCCESS_COUNT

常數值: "MODULE_RETRY_SUCCESS"

RETRY_TIME

public static final String RETRY_TIME

常數值: "MODULE_RETRY_TIME"

SPARSE_MODULE

public static final String SPARSE_MODULE

如果只回報模組層級事件,這個屬性會設為 true。

常數值: "sparse-module"

TEAR_DOWN_TIME

public static final String TEAR_DOWN_TIME

常數值: "TEARDOWN_TIME"

TEST_TIME

public static final String TEST_TIME

常數值: "TEST_TIME"

公用建構函式

ModuleDefinition

public ModuleDefinition ()

ModuleDefinition

public ModuleDefinition (String name, 
                 tests, 
                 preparersPerDevice, 
                 multiPreparers, 
                IConfiguration moduleConfig)

建構函式

參數
name String:測試設定的專屬名稱。

tests :需要執行的 IRemoteTest 清單。

preparersPerDevice :用於設定裝置的 ITargetPreparer 清單。

multiPreparers

moduleConfig IConfiguration:基礎模組設定的 IConfiguration

ModuleDefinition

public ModuleDefinition (String name, 
                 tests, 
                 preparersPerDevice, 
                 suitePreparersPerDevice, 
                 multiPreparers, 
                IConfiguration moduleConfig)

建構函式

參數
name String:測試設定的專屬名稱。

tests :需要執行的 IRemoteTest 清單。

preparersPerDevice :用於設定裝置的 ITargetPreparer 清單。

suitePreparersPerDevice

multiPreparers

moduleConfig IConfiguration:基礎模組設定的 IConfiguration

公用方法

compareTo

public int compareTo (ModuleDefinition moduleDef)

參數
moduleDef ModuleDefinition

傳回
int

getId

public String getId ()

傳回不重複的模組名稱。

傳回
String

getIntraModuleShardCount

public Integer getIntraModuleShardCount ()

傳回
Integer

getIntraModuleShardIndex

public Integer getIntraModuleShardIndex ()

傳回
Integer

getModuleConfiguration

public IConfiguration getModuleConfiguration ()

傳回
IConfiguration

getModuleInvocationContext

public IInvocationContext getModuleInvocationContext ()

傳回與模組相關聯的 IInvocationContext

傳回
IInvocationContext

getModuleTestInformation

public TestInformation getModuleTestInformation ()

傳回
TestInformation

getRequiredTokens

public  getRequiredTokens (TestInformation testInfo)

參數
testInfo TestInformation

傳回

getRuntimeHint

public long getRuntimeHint ()

傳回執行模組中所有測試的大約時間。

傳回
long

hasModuleFailed

public boolean hasModuleFailed ()

如果已對模組呼叫 testRunFailure,則傳回 True *

傳回
boolean

neededDevices

public int neededDevices ()

傳回預計會執行這項測試的裝置數量。

傳回
int

numTests

public int numTests ()

傳回目前等待執行的 IRemoteTest 數量。

傳回
int

reportNotExecuted

public final void reportNotExecuted (ITestInvocationListener listener, 
                String message)

回報完全未執行的模組。

參數
listener ITestInvocationListener

message String

得分

public final void run (TestInformation moduleInfo, 
                ITestInvocationListener listener, 
                int maxRunLimit)

執行模組中包含的所有 IRemoteTest,並使用前後的所有準備工具,設定及清除裝置。

參數
moduleInfo TestInformation:模組的 TestInformation

listener ITestInvocationListener:要回報結果的 ITestInvocationListener

maxRunLimit int:每個測試案例的執行次數上限。

擲回
DeviceNotAvailableException 以防裝置離線。

得分

public final void run (TestInformation moduleInfo, 
                ITestInvocationListener listener)

執行模組中包含的所有 IRemoteTest,並使用前後的所有準備工具,設定及清除裝置。

參數
moduleInfo TestInformation

listener ITestInvocationListener:要回報結果的 ITestInvocationListener

擲回
DeviceNotAvailableException 以防裝置離線。

runPreparation

public Throwable runPreparation (boolean includeSuitePreparers)

執行測試準備工具,包括套件層級準備工具 (如有指定)。

參數
includeSuitePreparers boolean:設為 true 即可一併執行套件層級的準備作業。

傳回
Throwable 執行準備程序時引發的任何例外狀況的 Throwable

setBuild

public void setBuild (IBuildInfo build)

插入測試期間要使用的 IBuildInfo

參數
build IBuildInfo

setCollectTestsOnly

public void setCollectTestsOnly (boolean collectTestsOnly)

啟用或停用測試收集模式

setDevice

public void setDevice (ITestDevice device)

插入測試期間要使用的 ITestDevice

參數
device ITestDevice

setEnableDynamicDownload

public void setEnableDynamicDownload (boolean enableDynamicDownload)

是否要在模組層級啟用動態下載。

參數
enableDynamicDownload boolean

setIntraModuleInformation

public void setIntraModuleInformation (int shardCount, 
                int shardIndex)

參數
shardCount int

shardIndex int

setLogSaver

public void setLogSaver (ILogSaver logSaver)

將叫用記錄儲存器傳遞至模組,以便在必要時使用。

參數
logSaver ILogSaver

setMergeAttemps

public final void setMergeAttemps (boolean mergeAttempts)

設定是否應合併結果。

參數
mergeAttempts boolean

setMetricCollectors

public void setMetricCollectors ( collectors)

將模組要使用的 IMetricCollector 清單注入模組。

參數
collectors

setRecoverVirtualDevice

public void setRecoverVirtualDevice (boolean recoverVirtualDevice)

集合應會復原虛擬裝置。

參數
recoverVirtualDevice boolean

setRemoveModuleBuffering

public void setRemoveModuleBuffering (boolean removeModuleBuffering)

參數
removeModuleBuffering boolean

setReportModuleEnd

public void setReportModuleEnd (boolean shouldReportModuleEnd)

參數
shouldReportModuleEnd boolean

setReportModuleStart

public void setReportModuleStart (boolean shouldReportModuleStart)

參數
shouldReportModuleStart boolean

setRetryDecision

public final void setRetryDecision (IRetryDecision decision)

設定用於模組內重試的 IRetryDecision

參數
decision IRetryDecision

setUseModuleResultsForwarder

public void setUseModuleResultsForwarder (boolean useModuleResultsForwarder)

參數
useModuleResultsForwarder boolean

shouldRecoverVirtualDevice

public boolean shouldRecoverVirtualDevice ()

傳回是否應復原虛擬裝置。

傳回
boolean

toString

public String toString ()

傳回
String

transferSuiteLevelOptions

public void transferSuiteLevelOptions (IConfiguration mSuiteConfiguration)

複製部分套件層級設定

參數
mSuiteConfiguration IConfiguration

受保護的方法

hasTests

protected boolean hasTests ()

如果模組的集區中仍有 IRemoteTest 要執行,則傳回 True。否則傳回「false」。

傳回
boolean