ModuleListener

public class ModuleListener
extends CollectingTestListener

java.lang.Object
   ↳ com.android.tradefed.result.CollectingTestListener
     ↳ com.android.tradefed.testtype.suite.ModuleListener


Listener attached to each IRemoteTest of each module in order to collect the list of results.

Summary

Public constructors

ModuleListener(ITestInvocationListener listener)

Constructor.

Public methods

int getNumTotalTests()

Gets the total number of complete tests for all runs.

boolean hasFailed()

Returns whether or not the listener session has failed.

void setMarkTestsSkipped(boolean skip)

Whether or not to mark all the test cases skipped.

void testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)

Alternative to testEnded(TestDescription, Map) where we can specify the end time directly.

void testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)

Reports the execution end of an individual test case.

void testFailed(TestDescription test, String trace)

Reports the failure of a individual test case.

void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

Called when the test log is saved.

void testRunFailed(String errorMessage)

Reports test run failed to complete due to a fatal error.

void testRunStarted(String name, int numTests)

Reports the start of a test run.

void testStarted(TestDescription test, long startTime)

Alternative to testStarted(TestDescription) where we also specify when the test was started, combined with testEnded(TestDescription, long, Map) for accurate measure.

Public constructors

ModuleListener

public ModuleListener (ITestInvocationListener listener)

Constructor.

Parameters
listener ITestInvocationListener

Public methods

getNumTotalTests

public int getNumTotalTests ()

Gets the total number of complete tests for all runs.

Returns
int

hasFailed

public boolean hasFailed ()

Returns whether or not the listener session has failed.

Returns
boolean

setMarkTestsSkipped

public void setMarkTestsSkipped (boolean skip)

Whether or not to mark all the test cases skipped.

Parameters
skip boolean

testEnded

public void testEnded (TestDescription test, 
                long endTime, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

Alternative to testEnded(TestDescription, Map) where we can specify the end time directly. Combine with testStarted(TestDescription, long) for accurate measure.

Parameters
test TestDescription: identifies the test

endTime long: the time the test ended, measured via System.currentTimeMillis()

testMetrics HashMap: a ERROR(/Map) of the metrics emitted

testEnded

public void testEnded (TestDescription test, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

Reports the execution end of an individual test case.

If testFailed(TestDescription, String) was not invoked, this test passed. Also returns any key/value metrics which may have been emitted during the test case's execution.

Parameters
test TestDescription: identifies the test

testMetrics HashMap: a ERROR(/Map) of the metrics emitted

testFailed

public void testFailed (TestDescription test, 
                String trace)

Reports the failure of a individual test case.

Will be called between testStarted and testEnded.

Parameters
test TestDescription: identifies the test

trace String: stack trace of failure

testLog

public void testLog (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

Must be called before ITestInvocationListener.invocationFailed(Throwable) or ITestInvocationListener.invocationEnded(long)

The TradeFederation framework will automatically call this method, providing the host log and if applicable, the device logcat.

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat". Note dataName may not be unique per invocation. ie implementers must be able to handle multiple calls with same dataName

dataType LogDataType: the LogDataType of the data

dataStream InputStreamSource: the InputStreamSource of the data. Implementers should call createInputStream to start reading the data, and ensure to close the resulting InputStream when complete. Callers should ensure the source of the data remains present and accessible until the testLog method completes.

testLogSaved

public void testLogSaved (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream, 
                LogFile logFile)

Called when the test log is saved.

Should be used in place of ITestLogger.testLog(String, LogDataType, InputStreamSource).

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat". Note dataName may not be unique per invocation. ie implementers must be able to handle multiple calls with same dataName

dataType LogDataType: the LogDataType of the data

dataStream InputStreamSource: the InputStreamSource of the data. Implementers should call createInputStream to start reading the data, and ensure to close the resulting InputStream when complete.

logFile LogFile: the LogFile containing the meta data of the saved file.

testRunFailed

public void testRunFailed (String errorMessage)

Reports test run failed to complete due to a fatal error.

Parameters
errorMessage String: String describing reason for run failure.

testRunStarted

public void testRunStarted (String name, 
                int numTests)

Reports the start of a test run.

Parameters
name String: the test run name

numTests int: total number of tests in test run

testStarted

public void testStarted (TestDescription test, 
                long startTime)

Alternative to testStarted(TestDescription) where we also specify when the test was started, combined with testEnded(TestDescription, long, Map) for accurate measure.

Parameters
test TestDescription: identifies the test

startTime long: the time the test started, measured via System.currentTimeMillis()