public class

CollectingTestListener

extends Object
implements ITestInvocationListener
java.lang.Object
   ↳ com.android.tradefed.result.CollectingTestListener
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

A ITestInvocationListener that will collect all test results.

Although the data structures used in this object are thread-safe, the ITestInvocationListener callbacks must be called in the correct order.

Summary

Public Constructors
CollectingTestListener()
Public Methods
IBuildInfo getBuildInfo()
Return the build info that was reported via invocationStarted(IBuildInfo)
TestRunResult getCurrentRunResults()
Gets the results for the current test run.
int getNumErrorTests()
Gets the total number of error tests for all runs.
int getNumFailedTests()
Gets the total number of failed tests for all runs.
int getNumIncompleteTests()
Gets the total number of incomplete tests for all runs.
int getNumPassedTests()
Gets the total number of passed tests for all runs.
int getNumTotalTests()
Gets the total number of complete tests for all runs.
Collection<TestRunResult> getRunResults()
Gets the results for all test runs.
TestSummary getSummary()
Allows the InvocationListener to return a summary.
boolean hasFailedTests()
void invocationEnded(long elapsedTime)
Reports that the invocation has terminated, whether successfully or due to some error condition.
void invocationFailed(Throwable cause)
Reports an incomplete invocation due to some error condition.
void invocationStarted(IBuildInfo buildInfo)
Reports the start of the test invocation.
void setBuildInfo(IBuildInfo buildInfo)
Set the build info.
void testEnded(TestIdentifier test, Map<String, String> testMetrics)
void testFailed(ITestRunListener.TestFailure testFailure, TestIdentifier test, String trace)
void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)
Provides the associated log or debug data from the test invocation.
void testRunEnded(long elapsedTime, Map<String, String> runMetrics)
void testRunFailed(String errorMessage)
void testRunStarted(String name, int numTests)
void testRunStopped(long elapsedTime)
void testStarted(TestIdentifier test)
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.ddmlib.testrunner.ITestRunListener
From interface com.android.tradefed.result.ITestInvocationListener

Public Constructors

public CollectingTestListener ()

Public Methods

public IBuildInfo getBuildInfo ()

Return the build info that was reported via invocationStarted(IBuildInfo)

public TestRunResult getCurrentRunResults ()

Gets the results for the current test run.

Note the results may not be complete. It is recommended to test the value of isRunComplete() and/or (@link TestRunResult#isRunFailure()} as appropriate before processing the results.

Returns
  • the TestRunResult representing data collected during last test run

public int getNumErrorTests ()

Gets the total number of error tests for all runs.

public int getNumFailedTests ()

Gets the total number of failed tests for all runs.

public int getNumIncompleteTests ()

Gets the total number of incomplete tests for all runs.

public int getNumPassedTests ()

Gets the total number of passed tests for all runs.

public int getNumTotalTests ()

Gets the total number of complete tests for all runs.

public Collection<TestRunResult> getRunResults ()

Gets the results for all test runs.

public TestSummary getSummary ()

Allows the InvocationListener to return a summary.

Returns

public boolean hasFailedTests ()

Returns
  • true if invocation had any failed or error tests.

public void invocationEnded (long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
elapsedTime the elapsed time of the invocation in ms

public void invocationFailed (Throwable cause)

Reports an incomplete invocation due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
cause the Throwable cause of the failure

public void invocationStarted (IBuildInfo buildInfo)

Reports the start of the test invocation.

Will be automatically called by the TradeFederation framework.

Parameters
buildInfo information about the build being tested

public void setBuildInfo (IBuildInfo buildInfo)

Set the build info.

public void testEnded (TestIdentifier test, Map<String, String> testMetrics)

public void testFailed (ITestRunListener.TestFailure testFailure, TestIdentifier test, String trace)

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

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

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

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

Parameters
dataName 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 the LogDataType of the data
dataStream 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.

public void testRunEnded (long elapsedTime, Map<String, String> runMetrics)

public void testRunFailed (String errorMessage)

public void testRunStarted (String name, int numTests)

public void testRunStopped (long elapsedTime)

public void testStarted (TestIdentifier test)