CollectingTestListener
public
class
CollectingTestListener
extends Object
implements
ITestInvocationListener,
ILogSaverListener
java.lang.Object | |
↳ | com.android.tradefed.result.CollectingTestListener |
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()
This method is deprecated.
rely on the |
TestRunResult
|
getCurrentRunResults()
Gets the results for the current test run. |
int
|
getExpectedTests()
Returns the number of expected tests count. |
IInvocationContext
|
getInvocationContext()
Return the invocation context that was reported via |
|
getMergedTestRunResults()
Return the merged collection of results for all runs across different attempts. |
IInvocationContext
|
getModuleContextForRunResult(String testRunName)
Returns the |
MultiMap<String, LogFile>
|
getModuleLogFiles()
Returns a copy of the map containing all the logged file associated with the module |
MultiMap<String, LogFile>
|
getNonAssociatedLogFiles()
Returns a copy of the map containing all the logged file not associated with a test run or a module. |
int
|
getNumAllFailedTestRuns()
Returns the total number of test runs in a failure state |
int
|
getNumAllFailedTests()
Returns the total number of tests in a failure state (only failed, assumption failures do not count toward it). |
int
|
getNumTestsInState(TestResult.TestStatus status)
Returns the number of tests in given state for this run. |
int
|
getNumTotalTests()
Returns the total number of complete tests for all runs. |
IBuildInfo
|
getPrimaryBuildInfo()
Return the primary build info that was reported via |
|
getRunResults()
This method is deprecated.
Use |
TestRunResult
|
getTestRunAtAttempt(String testRunName, int attempt)
Return the |
int
|
getTestRunAttemptCount(String testRunName)
Returns the number of attempts for a given test run name. |
|
getTestRunAttempts(String testRunName)
Gets all the attempts for a |
|
getTestRunForAttempts(int attempt)
Gets all the results for a given attempt. |
|
getTestRunNames()
Return all the names for all the test runs. |
boolean
|
hasFailedTests()
Returns if the invocation had any failed or assumption failed tests. |
boolean
|
hasTestRunResultsForName(String testRunName)
Returns whether a given test run name has any results. |
void
|
invocationEnded(long elapsedTime)
|
void
|
invocationFailed(Throwable cause)
|
void
|
invocationStarted(IInvocationContext context)
|
void
|
logAssociation(String dataName, LogFile logFile)
|
void
|
setBuildInfo(IBuildInfo buildInfo)
This method is deprecated. Not necessary for testing anymore. |
void
|
setMergeStrategy(MergeStrategy strategy)
Sets the |
void
|
testAssumptionFailure(TestDescription test, String trace)
|
void
|
testAssumptionFailure(TestDescription test, FailureDescription failure)
|
void
|
testEnded(TestDescription test, long endTime,
|
void
|
testEnded(TestDescription test,
|
void
|
testFailed(TestDescription test, FailureDescription failure)
|
void
|
testFailed(TestDescription test, String trace)
|
void
|
testIgnored(TestDescription test)
|
void
|
testModuleEnded()
|
void
|
testModuleStarted(IInvocationContext moduleContext)
|
void
|
testRunEnded(long elapsedTime,
|
void
|
testRunFailed(FailureDescription failure)
|
void
|
testRunFailed(String errorMessage)
|
void
|
testRunStarted(String name, int numTests, int attemptNumber)
|
void
|
testRunStarted(String name, int numTests)
|
void
|
testRunStarted(String name, int numTests, int attemptNumber, long startTime)
|
void
|
testRunStopped(long elapsedTime)
|
void
|
testStarted(TestDescription test, long startTime)
|
void
|
testStarted(TestDescription test)
|
Protected methods | |
---|---|
final
void
|
clearModuleLogFiles()
Allows cleaning the module file so we avoid carrying them for too long. |
final
void
|
clearResultsForName(String testRunName)
Allows to clear the results for a given run name. |
void
|
setIsAggregrateMetrics(boolean aggregate)
Toggle the 'aggregate metrics' option |
Public constructors
CollectingTestListener
public CollectingTestListener ()
Public methods
getBuildInfo
public IBuildInfo getBuildInfo ()
This method is deprecated.
rely on the IBuildInfo
from getInvocationContext()
.
Returns the build info.
Returns | |
---|---|
IBuildInfo |
getCurrentRunResults
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 TestRunResult.isRunComplete()
and/or (@link TestRunResult#isRunFailure()} as appropriate
before processing the results.
Returns | |
---|---|
TestRunResult |
the TestRunResult representing data collected during last test run
|
getExpectedTests
public int getExpectedTests ()
Returns the number of expected tests count. Could differ from getNumTotalTests()
if
some tests did not run.
Returns | |
---|---|
int |
getInvocationContext
public IInvocationContext getInvocationContext ()
Return the invocation context that was reported via invocationStarted(com.android.tradefed.invoker.IInvocationContext)
Returns | |
---|---|
IInvocationContext |
getMergedTestRunResults
publicgetMergedTestRunResults ()
Return the merged collection of results for all runs across different attempts.
If there are multiple results, each test run is merged, with the latest test result overwriting test results of previous runs. Test runs are ordered by attempt number.
Metrics for the same attempt will be merged based on the preference set by aggregate-metrics
. The final metrics will be the metrics of the last attempt.
Returns | |
---|---|
|
getModuleContextForRunResult
public IInvocationContext getModuleContextForRunResult (String testRunName)
Returns the IInvocationContext
of the module associated with the results.
Parameters | |
---|---|
testRunName |
String : The name given by {testRunStarted(String, int) . |
Returns | |
---|---|
IInvocationContext |
The IInvocationContext of the module for a given test run name null
if there are no results for that name.
|
getModuleLogFiles
public MultiMap<String, LogFile> getModuleLogFiles ()
Returns a copy of the map containing all the logged file associated with the module
Returns | |
---|---|
MultiMap<String, LogFile> |
getNonAssociatedLogFiles
public MultiMap<String, LogFile> getNonAssociatedLogFiles ()
Returns a copy of the map containing all the logged file not associated with a test run or a module.
Returns | |
---|---|
MultiMap<String, LogFile> |
getNumAllFailedTestRuns
public int getNumAllFailedTestRuns ()
Returns the total number of test runs in a failure state
Returns | |
---|---|
int |
getNumAllFailedTests
public int getNumAllFailedTests ()
Returns the total number of tests in a failure state (only failed, assumption failures do not count toward it).
Returns | |
---|---|
int |
getNumTestsInState
public int getNumTestsInState (TestResult.TestStatus status)
Returns the number of tests in given state for this run.
Parameters | |
---|---|
status |
TestResult.TestStatus |
Returns | |
---|---|
int |
getNumTotalTests
public int getNumTotalTests ()
Returns the total number of complete tests for all runs.
Returns | |
---|---|
int |
getPrimaryBuildInfo
public IBuildInfo getPrimaryBuildInfo ()
Return the primary build info that was reported via invocationStarted(com.android.tradefed.invoker.IInvocationContext)
. Primary build is the build returned by the first
build provider of the running configuration. Returns null if there is no context (no build to
test case).
Returns | |
---|---|
IBuildInfo |
getRunResults
publicgetRunResults ()
This method is deprecated.
Use getMergedTestRunResults()
Returns the results for all test runs.
Returns | |
---|---|
|
getTestRunAtAttempt
public TestRunResult getTestRunAtAttempt (String testRunName, int attempt)
Return the TestRunResult
for a single attempt.
Parameters | |
---|---|
testRunName |
String : The name given by {testRunStarted(String, int) . |
attempt |
int : The attempt id. |
Returns | |
---|---|
TestRunResult |
The TestRunResult for the given name and attempt id or null if it
does not exist.
|
getTestRunAttemptCount
public int getTestRunAttemptCount (String testRunName)
Returns the number of attempts for a given test run name.
Parameters | |
---|---|
testRunName |
String : The name given by {testRunStarted(String, int) .
|
Returns | |
---|---|
int |
getTestRunAttempts
publicgetTestRunAttempts (String testRunName)
Gets all the attempts for a TestRunResult
of a given test run.
Parameters | |
---|---|
testRunName |
String : The name given by {testRunStarted(String, int) . |
Returns | |
---|---|
|
All TestRunResult for a given test run, ordered by attempts.
|
getTestRunForAttempts
publicgetTestRunForAttempts (int attempt)
Gets all the results for a given attempt.
Parameters | |
---|---|
attempt |
int : The attempt we want results for. |
Returns | |
---|---|
|
All TestRunResult for a given attempt.
|
getTestRunNames
publicgetTestRunNames ()
Return all the names for all the test runs.
These test runs may have run multiple times with different attempts.
Returns | |
---|---|
|
hasFailedTests
public boolean hasFailedTests ()
Returns if the invocation had any failed or assumption failed tests.
Returns | |
---|---|
boolean |
hasTestRunResultsForName
public boolean hasTestRunResultsForName (String testRunName)
Returns whether a given test run name has any results.
Parameters | |
---|---|
testRunName |
String : The name given by {testRunStarted(String, int) .
|
Returns | |
---|---|
boolean |
invocationEnded
public void invocationEnded (long elapsedTime)
Parameters | |
---|---|
elapsedTime |
long |
invocationFailed
public void invocationFailed (Throwable cause)
Parameters | |
---|---|
cause |
Throwable |
invocationStarted
public void invocationStarted (IInvocationContext context)
Parameters | |
---|---|
context |
IInvocationContext |
logAssociation
public void logAssociation (String dataName, LogFile logFile)
Parameters | |
---|---|
dataName |
String |
logFile |
LogFile |
setBuildInfo
public void setBuildInfo (IBuildInfo buildInfo)
This method is deprecated.
Not necessary for testing anymore.
Set the build info. Should only be used for testing.
Parameters | |
---|---|
buildInfo |
IBuildInfo |
setMergeStrategy
public void setMergeStrategy (MergeStrategy strategy)
Sets the MergeStrategy
to use when merging results.
Parameters | |
---|---|
strategy |
MergeStrategy |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, String trace)
Parameters | |
---|---|
test |
TestDescription |
trace |
String |
testAssumptionFailure
public void testAssumptionFailure (TestDescription test, FailureDescription failure)
Parameters | |
---|---|
test |
TestDescription |
failure |
FailureDescription |
testEnded
public void testEnded (TestDescription test, long endTime,testMetrics)
Parameters | |
---|---|
test |
TestDescription |
endTime |
long |
testMetrics |
|
testEnded
public void testEnded (TestDescription test,testMetrics)
Parameters | |
---|---|
test |
TestDescription |
testMetrics |
|
testFailed
public void testFailed (TestDescription test, FailureDescription failure)
Parameters | |
---|---|
test |
TestDescription |
failure |
FailureDescription |
testFailed
public void testFailed (TestDescription test, String trace)
Parameters | |
---|---|
test |
TestDescription |
trace |
String |
testIgnored
public void testIgnored (TestDescription test)
Parameters | |
---|---|
test |
TestDescription |
testModuleEnded
public void testModuleEnded ()
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
Parameters | |
---|---|
moduleContext |
IInvocationContext |
testRunEnded
public void testRunEnded (long elapsedTime,runMetrics)
Parameters | |
---|---|
elapsedTime |
long |
runMetrics |
|
testRunFailed
public void testRunFailed (FailureDescription failure)
Parameters | |
---|---|
failure |
FailureDescription |
testRunFailed
public void testRunFailed (String errorMessage)
Parameters | |
---|---|
errorMessage |
String |
testRunStarted
public void testRunStarted (String name, int numTests, int attemptNumber)
Parameters | |
---|---|
name |
String |
numTests |
int |
attemptNumber |
int |
testRunStarted
public void testRunStarted (String name, int numTests)
Parameters | |
---|---|
name |
String |
numTests |
int |
testRunStarted
public void testRunStarted (String name, int numTests, int attemptNumber, long startTime)
Parameters | |
---|---|
name |
String |
numTests |
int |
attemptNumber |
int |
startTime |
long |
testRunStopped
public void testRunStopped (long elapsedTime)
Parameters | |
---|---|
elapsedTime |
long |
testStarted
public void testStarted (TestDescription test, long startTime)
Parameters | |
---|---|
test |
TestDescription |
startTime |
long |
testStarted
public void testStarted (TestDescription test)
Parameters | |
---|---|
test |
TestDescription |
Protected methods
clearModuleLogFiles
protected final void clearModuleLogFiles ()
Allows cleaning the module file so we avoid carrying them for too long.
clearResultsForName
protected final void clearResultsForName (String testRunName)
Allows to clear the results for a given run name. Should only be used in some cases like the aggregator of results.
Parameters | |
---|---|
testRunName |
String |
setIsAggregrateMetrics
protected void setIsAggregrateMetrics (boolean aggregate)
Toggle the 'aggregate metrics' option
Parameters | |
---|---|
aggregate |
boolean |