IMetricCollector

public interface IMetricCollector
implements IDisableable, ILogSaverListener

com.android.tradefed.device.metric.IMetricCollector


在报告测试结果时,此接口将作为装饰器添加,以便收集匹配的指标。

即使此接口扩展了 ITestInvocationListener,也无法用作 。配置检查会拒绝该配置。必须用作“metrics_collector”。

收集器不应保留内部状态,因为它们可能会在多个位置重复使用。如果确实必须使用内部状态,则应在 init(com.android.tradefed.invoker.IInvocationContext, com.android.tradefed.result.ITestInvocationListener) 上清理该状态。

摘要

公共方法

default boolean captureModuleLevel()

收集器是否适用于模块级捕获,是否应进行初始化。

abstract getBuildInfos()

返回调用中可用的 build 信息列表。

abstract getDevices()

返回调用中可用的设备列表。

abstract ITestInvocationListener getInvocationListener()

返回转发结果的原始 ITestInvocationListener

abstract ITestInvocationListener init(IInvocationContext context, ITestInvocationListener listener)

使用当前上下文初始化收集器,并指定结果的转发位置。

abstract void onTestAssumptionFailure(DeviceMetricData testData, TestDescription test)

在测试用例因假设失败而失败时的回调。

abstract void onTestEnd(DeviceMetricData testData, currentTestCaseMetrics, TestDescription test)

测试用例结束时的回调。

abstract void onTestEnd(DeviceMetricData testData, currentTestCaseMetrics)

测试用例结束时的回调。

abstract void onTestFail(DeviceMetricData testData, TestDescription test)

测试用例失败时的回调。

default void onTestModuleEnded()

允许捕获模块结束事件。

default void onTestModuleStarted()

允许捕获模块启动事件。

abstract void onTestRunEnd(DeviceMetricData runData, currentRunMetrics)

测试运行结束时的回调。

abstract void onTestRunStart(DeviceMetricData runData)

测试运行开始时的回调。

default void onTestRunStart(DeviceMetricData runData, int testCount)

测试运行开始时的回调。

abstract void onTestStart(DeviceMetricData testData)

测试用例开始时的回调。

公共方法

captureModuleLevel

public boolean captureModuleLevel ()

收集器是否适用于模块级捕获,是否应进行初始化。

返回
boolean

getBuildInfos

public abstract  getBuildInfos ()

返回调用中可用的 build 信息列表。

返回

getDevices

public abstract  getDevices ()

返回调用中可用的设备列表。

返回

getInvocationListener

public abstract ITestInvocationListener getInvocationListener ()

返回转发结果的原始 ITestInvocationListener

返回
ITestInvocationListener

init

public abstract ITestInvocationListener init (IInvocationContext context, 
                ITestInvocationListener listener)

使用当前上下文初始化收集器,并指定结果转发位置。每个实例只会调用一次,并且收集器应更新其内部上下文和监听器。在测试运行期间,系统绝不会调用 init,而是在测试运行之前调用 init。

除非您知道自己在做什么,否则请勿替换。

参数
context IInvocationContext:正在进行的调用的 IInvocationContext

listener ITestInvocationListener:用于放置结果的 ITestInvocationListener

返回
ITestInvocationListener 封装原始监听器的新监听器。

抛出
DeviceNotAvailableException

onTestAssumptionFailure

public abstract void onTestAssumptionFailure (DeviceMetricData testData, 
                TestDescription test)

测试用例因假设失败而失败时的回调。

参数
testData DeviceMetricData:用于保存测试用例数据的 DeviceMetricData

test TestDescription:正在进行的测试用例的 TestDescription

抛出
DeviceNotAvailableException

onTestEnd

public abstract void onTestEnd (DeviceMetricData testData, 
                 currentTestCaseMetrics, 
                TestDescription test)

测试用例结束时的回调。现在应该进行清理。

参数
testData DeviceMetricData:用于保存测试用例数据的 DeviceMetricData。将与 onTestStart(com.android.tradefed.device.metric.DeviceMetricData) 期间的对象相同。

currentTestCaseMetrics :传递给 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) 的当前指标映射。

test TestDescription:正在进行的测试用例的 TestDescription

抛出
DeviceNotAvailableException

onTestEnd

public abstract void onTestEnd (DeviceMetricData testData, 
                 currentTestCaseMetrics)

测试用例结束时的回调。现在应该进行清理。

参数
testData DeviceMetricData:用于保存测试用例数据的 DeviceMetricData。将与 onTestStart(com.android.tradefed.device.metric.DeviceMetricData) 期间的对象相同。

currentTestCaseMetrics :传递给 ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map)) 的当前指标映射。

抛出
DeviceNotAvailableException

onTestFail

public abstract void onTestFail (DeviceMetricData testData, 
                TestDescription test)

测试用例失败时的回调。

参数
testData DeviceMetricData:用于保存测试用例数据的 DeviceMetricData

test TestDescription:正在进行的测试用例的 TestDescription

抛出
DeviceNotAvailableException

onTestModuleEnded

public void onTestModuleEnded ()

允许捕获模块结束事件。

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

onTestModuleStarted

public void onTestModuleStarted ()

允许捕获模块启动事件。

抛出
com.android.tradefed.device.DeviceNotAvailableException
DeviceNotAvailableException

onTestRunEnd

public abstract void onTestRunEnd (DeviceMetricData runData, 
                 currentRunMetrics)

测试运行结束时的回调。现在应该进行清理。

参数
runData DeviceMetricData:用于保存运行数据的 DeviceMetricData。与 onTestRunStart(com.android.tradefed.device.metric.DeviceMetricData) 期间的对象相同。

currentRunMetrics :传递给 ERROR(/#testRunEnded(long,Map)) 的当前指标映射。

抛出
DeviceNotAvailableException

onTestRunStart

public abstract void onTestRunStart (DeviceMetricData runData)

测试运行开始时的回调。

参数
runData DeviceMetricData:用于保存运行数据的 DeviceMetricData

抛出
DeviceNotAvailableException

onTestRunStart

public void onTestRunStart (DeviceMetricData runData, 
                int testCount)

测试运行开始时的回调。

参数
runData DeviceMetricData:用于保存运行数据的 DeviceMetricData

testCount int:相应测试运行中的测试用例数量。

抛出
DeviceNotAvailableException

onTestStart

public abstract void onTestStart (DeviceMetricData testData)

测试用例开始时的回调。

参数
testData DeviceMetricData:用于保存测试用例数据的 DeviceMetricData

抛出
DeviceNotAvailableException