IMetricCollector

public interface IMetricCollector
implements ITestInvocationListener

com.android.tradefed.device.metric.IMetricCollector


This interface will be added as a decorator when reporting tests results in order to collect matching metrics.

This interface cannot be used as a even it extends ITestInvocationListener. The configuration checking will reject it. It must be used as a "metrics_collector".

Collectors are not expected to keep an internal state as they may be re-used in several places. If an internal state really must be used, then it should be cleaned on init(IInvocationContext, ITestInvocationListener).

Summary

Public methods

abstract List<IBuildInfo> getBuildInfos()

Returns the list of build information available in the invocation.

abstract List<ITestDevice> getDevices()

Returns the list of devices available in the invocation.

abstract ITestInvocationListener getInvocationListener()

Returns the original ITestInvocationListener where we are forwarding the results.

abstract ITestInvocationListener init(IInvocationContext context, ITestInvocationListener listener)

Initialization of the collector with the current context and where to forward results.

abstract void onTestEnd(DeviceMetricData testData, Map<String, MetricMeasurement.Metric> currentTestCaseMetrics)

Callback when a test case is ended.

abstract void onTestRunEnd(DeviceMetricData runData, Map<String, MetricMeasurement.Metric> currentRunMetrics)

Callback when a test run is ended.

abstract void onTestRunStart(DeviceMetricData runData)

Callback when a test run is started.

abstract void onTestStart(DeviceMetricData testData)

Callback when a test case is started.

Public methods

getBuildInfos

public abstract List<IBuildInfo> getBuildInfos ()

Returns the list of build information available in the invocation.

Returns
List<IBuildInfo>

getDevices

public abstract List<ITestDevice> getDevices ()

Returns the list of devices available in the invocation.

Returns
List<ITestDevice>

getInvocationListener

public abstract ITestInvocationListener getInvocationListener ()

Returns the original ITestInvocationListener where we are forwarding the results.

Returns
ITestInvocationListener

init

public abstract ITestInvocationListener init (IInvocationContext context, 
                ITestInvocationListener listener)

Initialization of the collector with the current context and where to forward results. Will only be called once per instance, and the collector is expected to update its internal context and listener. Init will never be called during a test run always before.

Do not override unless you know what you are doing.

Parameters
context IInvocationContext: the IInvocationContext for the invocation in progress.

listener ITestInvocationListener: the ITestInvocationListener where to put results.

Returns
ITestInvocationListener the new listener wrapping the original one.

onTestEnd

public abstract void onTestEnd (DeviceMetricData testData, 
                Map<String, MetricMeasurement.Metric> currentTestCaseMetrics)

Callback when a test case is ended. This should be the time for clean up.

Parameters
testData DeviceMetricData: the DeviceMetricData holding the data for the test case. Will be the same object as during onTestStart(DeviceMetricData).

currentTestCaseMetrics Map: the current map of metrics passed to ITestLifeCycleReceiver.testEnded(TestDescription, Map).

onTestRunEnd

public abstract void onTestRunEnd (DeviceMetricData runData, 
                Map<String, MetricMeasurement.Metric> currentRunMetrics)

Callback when a test run is ended. This should be the time for clean up.

Parameters
runData DeviceMetricData: the DeviceMetricData holding the data for the run. Will be the same object as during onTestRunStart(DeviceMetricData).

currentRunMetrics Map: the current map of metrics passed to ITestLifeCycleReceiver.testRunEnded(long, Map).

onTestRunStart

public abstract void onTestRunStart (DeviceMetricData runData)

Callback when a test run is started.

Parameters
runData DeviceMetricData: the DeviceMetricData holding the data for the run.

onTestStart

public abstract void onTestStart (DeviceMetricData testData)

Callback when a test case is started.

Parameters
testData DeviceMetricData: the DeviceMetricData holding the data for the test case.