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)

报告完全未执行的模块。

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