模块定义

public class ModuleDefinition
extends Object implements ITestCollector

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


测试运行配置的容器。这个类是准备和运行测试的助手。

概括

领域

public static final String ISOLATION_COST

public static final String MODULE_ABI

public static final String MODULE_CACHED

如果测试模块结果已缓存,则此属性设置为 true。

public static final String MODULE_CONTROLLER

public static final String MODULE_EXTERNAL_DEPENDENCIES

public static final String MODULE_ID

模块 ID 将在 testRunStart 期间用于唯一标识模块的名称。

public static final String MODULE_ISOLATED

如果模块在新准备的设备上运行,则此属性设置为 true。

public static final String MODULE_NAME

模块名称是与模块关联的基本名称,通常来自加载模块的 Xml TF 配置文件。

public static final String MODULE_PARAMETERIZATION

public static final String MODULE_TEST_COUNT

public static final String PREPARATION_TIME

public static final String RETRY_FAIL_COUNT

public static final String RETRY_SUCCESS_COUNT

public static final String RETRY_TIME

public static final String SPARSE_MODULE

如果仅报告模块级事件,则此属性设置为 true。

public static final String TEAR_DOWN_TIME

public static final String TEST_TIME

公共构造函数

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

构造函数

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

构造函数

公共方法

int compareTo ( ModuleDefinition moduleDef)

String getId ()

返回唯一的模块名称。

IConfiguration getModuleConfiguration ()
IInvocationContext getModuleInvocationContext ()

返回与模块关联的IInvocationContext

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, moduleLevelListeners, TestFailureListener failureListener, int maxRunLimit) run ( TestInformation moduleInfo, ITestInvocationListener listener, moduleLevelListeners, TestFailureListener failureListener, int maxRunLimit)

运行模块中包含的所有IRemoteTest ,并使用之前和之后的所有准备器来设置和清理设备。

final void run ( TestInformation moduleInfo, ITestInvocationListener listener, moduleLevelListeners, TestFailureListener failureListener) run ( TestInformation moduleInfo, ITestInvocationListener listener, moduleLevelListeners, TestFailureListener failureListener)

运行模块中包含的所有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 setLogSaver ( ILogSaver logSaver)

将调用日志保存程序传递给模块,以便模块可以在必要时使用它。

final void setMergeAttemps (boolean mergeAttempts)

设置是否应该合并结果。

void setMetricCollectors ( collectors) setMetricCollectors ( collectors)

注入模块要使用的IMetricCollector列表。

void setRecoverVirtualDevice (boolean recoverVirtualDevice)

设置应该恢复虚拟设备。

final void setRetryDecision ( IRetryDecision decision)

设置用于模块内重试的IRetryDecision

boolean shouldRecoverVirtualDevice ()

返回我们是否应该恢复虚拟设备。

String toString ()

void transferSuiteLevelOptions ( IConfiguration mSuiteConfiguration)

复制一些套件级别的配置

受保护的方法

boolean hasTests ()

如果模块仍有IRemoteTest要在其池中运行,则返回 True。

领域

隔离成本

public static final String ISOLATION_COST

模块_ABI

public static final String MODULE_ABI

模块_缓存

public static final String MODULE_CACHED

如果测试模块结果已缓存,则此属性设置为 true。

模块控制器

public static final String MODULE_CONTROLLER

MODULE_EXTERNAL_DEPENDENCIES

public static final String MODULE_EXTERNAL_DEPENDENCIES

模块ID

public static final String MODULE_ID

模块 ID 将在 testRunStart 期间用于唯一标识模块的名称。它通常是 MODULE_ABI + MODULE_NAME 的组合。

模块_隔离

public static final String MODULE_ISOLATED

如果模块在新准备的设备上运行,则此属性设置为 true。

模块名称

public static final String MODULE_NAME

模块名称是与模块关联的基本名称,通常来自加载模块的 Xml TF 配置文件。

模块参数化

public static final String MODULE_PARAMETERIZATION

MODULE_TEST_COUNT

public static final String MODULE_TEST_COUNT

准备时间

public static final String PREPARATION_TIME

重试失败次数

public static final String RETRY_FAIL_COUNT

RETRY_SUCCESS_COUNT 次

public static final String RETRY_SUCCESS_COUNT

重试时间

public static final String RETRY_TIME

稀疏模块

public static final String SPARSE_MODULE

如果仅报告模块级事件,则此属性设置为 true。

TEAR_DOWN_TIME

public static final String TEAR_DOWN_TIME

测试时间

public static final String TEST_TIME

公共构造函数

模块定义

public ModuleDefinition ()

模块定义

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

构造函数

参数
name String :测试配置的唯一名称。

tests :需要运行的IRemoteTest列表。

preparersPerDevice :用于设置设备的ITargetPreparer列表。

multiPreparers

moduleConfig IConfiguration :底层模块配置的IConfiguration

模块定义

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

构造函数

参数
name String :测试配置的唯一名称。

tests :需要运行的IRemoteTest列表。

preparersPerDevice :用于设置设备的ITargetPreparer列表。

suitePreparersPerDevice

multiPreparers

moduleConfig IConfiguration :底层模块配置的IConfiguration

公共方法

相比于

public int compareTo (ModuleDefinition moduleDef)

参数
moduleDef ModuleDefinition

退货
int

获取ID

public String getId ()

返回唯一的模块名称。

退货
String

获取模块配置

public IConfiguration getModuleConfiguration ()

退货
IConfiguration

获取模块调用上下文

public IInvocationContext getModuleInvocationContext ()

返回与模块关联的IInvocationContext

退货
IInvocationContext

获取所需令牌

public  getRequiredTokens (TestInformation testInfo)

参数
testInfo TestInformation

退货

获取运行时提示

public long getRuntimeHint ()

返回运行模块中所有测试的大致时间。

退货
long

模块失败

public boolean hasModuleFailed ()

如果已在模块上调用 testRunFailure,则返回 True *

退货
boolean

所需设备

public int neededDevices ()

返回预计运行此测试的设备数量。

退货
int

测试次数

public int numTests ()

返回当前等待执行的IRemoteTest数量。

退货
int

报告未执行

public final void reportNotExecuted (ITestInvocationListener listener, 
                String message)

完全报告未执行的模块。

参数
listener ITestInvocationListener

message String

跑步

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

运行模块中包含的所有IRemoteTest ,并使用之前和之后的所有准备器来设置和清理设备。

参数
moduleInfo TestInformation :模块的TestInformation

listener ITestInvocationListenerITestInvocationListener报告结果的位置。

moduleLevelListeners :模块级别的侦听器列表。

failureListener TestFailureListener :收集 testFail 日志的特定侦听器。可以为空。

maxRunLimit int :每个测试用例的最大运行次数。

投掷
DeviceNotAvailableException如果设备离线。

跑步

public final void run (TestInformation moduleInfo, 
                ITestInvocationListener listener, 
                 moduleLevelListeners, 
                TestFailureListener failureListener)

运行模块中包含的所有IRemoteTest ,并使用之前和之后的所有准备器来设置和清理设备。

参数
moduleInfo TestInformation

listener ITestInvocationListenerITestInvocationListener报告结果的位置。

moduleLevelListeners :模块级别的侦听器列表。

failureListener TestFailureListener :收集 testFail 日志的特定侦听器。可以为空。

投掷
DeviceNotAvailableException如果设备离线。

跑步

public final void run (TestInformation moduleInfo, 
                ITestInvocationListener listener)

运行模块中包含的所有IRemoteTest ,并使用之前和之后的所有准备器来设置和清理设备。

参数
moduleInfo TestInformation

listener ITestInvocationListenerITestInvocationListener报告结果的位置。

投掷
DeviceNotAvailableException如果设备离线。

运行准备

public Throwable runPreparation (boolean includeSuitePreparers)

运行测试的准备器,包括套件级准备器(如果指定)。

参数
includeSuitePreparers boolean :设置为true也可以运行套件级别的准备器。

退货
Throwable运行准备器时引发的任何异常Throwable

设置构建

public void setBuild (IBuildInfo build)

注入要在测试期间使用的IBuildInfo

参数
build IBuildInfo

仅设置收集测试

public void setCollectTestsOnly (boolean collectTestsOnly)

启用或禁用测试收集模式

设置设备

public void setDevice (ITestDevice device)

注入要在测试期间使用的ITestDevice

参数
device ITestDevice

设置启用动态下载

public void setEnableDynamicDownload (boolean enableDynamicDownload)

是否在模块级别启用动态下载。

参数
enableDynamicDownload boolean

设置日志保存程序

public void setLogSaver (ILogSaver logSaver)

将调用日志保存程序传递给模块,以便模块可以在必要时使用它。

参数
logSaver ILogSaver

设置合并尝试

public final void setMergeAttemps (boolean mergeAttempts)

设置是否应该合并结果。

参数
mergeAttempts boolean

设置MetricCollectors

public void setMetricCollectors ( collectors)

注入模块要使用的IMetricCollector列表。

参数
collectors

设置恢复虚拟设备

public void setRecoverVirtualDevice (boolean recoverVirtualDevice)

设置应该恢复虚拟设备。

参数
recoverVirtualDevice boolean

设置重试决策

public final void setRetryDecision (IRetryDecision decision)

设置用于模块内重试的IRetryDecision

参数
decision IRetryDecision

应该恢复虚拟设备

public boolean shouldRecoverVirtualDevice ()

返回我们是否应该恢复虚拟设备。

退货
boolean

到字符串

public String toString ()

退货
String

传输套件级别选项

public void transferSuiteLevelOptions (IConfiguration mSuiteConfiguration)

复制一些套件级别的配置

参数
mSuiteConfiguration IConfiguration

受保护的方法

有测试

protected boolean hasTests ()

如果模块仍有IRemoteTest要在其池中运行,则返回 True。否则为假。

退货
boolean