SubprocessResultsReporter
public
class
SubprocessResultsReporter
extends Object
implements
ILogSaverListener,
ISupportGranularResults,
ITestInvocationListener
java.lang.Object | |
↳ | com.android.tradefed.result.SubprocessResultsReporter |
Implements ITestInvocationListener
to be specified as a result_reporter and forward from
the subprocess the results of tests, test runs, test invocations.
Summary
Public constructors | |
---|---|
SubprocessResultsReporter()
|
Public methods | |
---|---|
void
|
close()
|
TestSummary
|
getSummary()
Allows the InvocationListener to return a summary. |
void
|
invocationEnded(long elapsedTime)
Reports that the invocation has terminated, whether successfully or due to some error condition. |
void
|
invocationFailed(FailureDescription failure)
Reports an incomplete invocation due to some error condition. |
void
|
invocationFailed(Throwable cause)
Reports an incomplete invocation due to some error condition. |
void
|
invocationStarted(IInvocationContext context)
Reports the start of the test invocation. |
void
|
logAssociation(String dataName, LogFile logFile)
In some cases, log must be strongly associated with a test cases, but the opportunity to do
so on the direct |
void
|
printEvent(String key, Object event)
Helper to print the event key and then the json object. |
void
|
setOutputTestLog(boolean outputTestLog)
Sets whether or not we should output the test logged or not. |
boolean
|
supportGranularResults()
Returns True if the reporter support granular results, false otherwise. |
void
|
testAssumptionFailure(TestDescription testId, String trace)
Called when an atomic test flags that it assumes a condition that is false |
void
|
testAssumptionFailure(TestDescription testId, FailureDescription failure)
Called when an atomic test flags that it assumes a condition that is false |
void
|
testEnded(TestDescription testId, long endTime,
Alternative to |
void
|
testEnded(TestDescription testId,
Reports the execution end of an individual test case. |
void
|
testFailed(TestDescription testId, FailureDescription failure)
Reports the failure of a individual test case. |
void
|
testFailed(TestDescription testId, String reason)
Reports the failure of a individual test case. |
void
|
testIgnored(TestDescription testId)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore. |
void
|
testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)
Provides the associated log or debug data from the test invocation. |
void
|
testModuleEnded()
Reports the end of a module run. |
void
|
testModuleStarted(IInvocationContext moduleContext)
Reports the beginning of a module running. |
void
|
testRunEnded(long time,
Reports end of test run. |
void
|
testRunFailed(FailureDescription failure)
Reports test run failed to complete due to a failure described by |
void
|
testRunFailed(String reason)
Reports test run failed to complete due to a fatal error. |
void
|
testRunStarted(String runName, int testCount, int attemptNumber)
Reports the start of a test run. |
void
|
testRunStarted(String runName, int testCount)
Reports the start of a test run. |
void
|
testRunStarted(String runName, int testCount, int attemptNumber, long startTime)
Reports the start of a test run. |
void
|
testRunStopped(long arg0)
Reports test run stopped before completion due to a user request. |
void
|
testSkipped(TestDescription testId, SkipReason reason)
Called when a test is skipped and did not execute for a reason that is not usually expected. |
void
|
testStarted(TestDescription testId, long startTime)
Alternative to |
void
|
testStarted(TestDescription testId)
Reports the start of an individual test case. |
Public constructors
SubprocessResultsReporter
public SubprocessResultsReporter ()
Public methods
close
public void close ()
getSummary
public TestSummary getSummary ()
Allows the InvocationListener to return a summary.
Returns | |
---|---|
TestSummary |
A TestSummary summarizing the run, or null |
invocationEnded
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 |
long : the elapsed time of the invocation in ms |
invocationFailed
public void invocationFailed (FailureDescription failure)
Reports an incomplete invocation due to some error condition.
Will be automatically called by the TradeFederation framework.
Parameters | |
---|---|
failure |
FailureDescription : the FailureDescription describing the cause of the failure |
invocationFailed
public void invocationFailed (Throwable cause)
Reports an incomplete invocation due to some error condition.
Will be automatically called by the TradeFederation framework.Parameters | |
---|---|
cause |
Throwable : the Throwable cause of the failure |
invocationStarted
public void invocationStarted (IInvocationContext context)
Reports the start of the test invocation.
Will be automatically called by the TradeFederation framework. Reporters need to override this method to support multiple devices reporting.
Parameters | |
---|---|
context |
IInvocationContext : information about the invocation |
logAssociation
public void logAssociation (String dataName, LogFile logFile)
In some cases, log must be strongly associated with a test cases, but the opportunity to do
so on the direct testLogSaved(String, com.android.tradefed.result.LogDataType, com.android.tradefed.result.InputStreamSource, com.android.tradefed.result.LogFile)
callback is not possible. Thus, this callback allows to provide a strong association
explicitly.
Parameters | |
---|---|
dataName |
String : The name of the data |
logFile |
LogFile : the LogFile that was logged before and should be associated with the
test case. |
printEvent
public void printEvent (String key, Object event)
Helper to print the event key and then the json object.
Parameters | |
---|---|
key |
String |
event |
Object |
setOutputTestLog
public void setOutputTestLog (boolean outputTestLog)
Sets whether or not we should output the test logged or not.
Parameters | |
---|---|
outputTestLog |
boolean |
supportGranularResults
public boolean supportGranularResults ()
Returns True if the reporter support granular results, false otherwise.
Returns | |
---|---|
boolean |
testAssumptionFailure
public void testAssumptionFailure (TestDescription testId, String trace)
Called when an atomic test flags that it assumes a condition that is false
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
trace |
String : stack trace of failure |
testAssumptionFailure
public void testAssumptionFailure (TestDescription testId, FailureDescription failure)
Called when an atomic test flags that it assumes a condition that is false
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
failure |
FailureDescription : FailureDescription describing the failure and its context. |
testEnded
public void testEnded (TestDescription testId, long endTime,metrics)
Alternative to ERROR(/#testEnded(com.android.tradefed.result.TestDescription,Map))
where we can specify the end time
directly. Combine with testStarted(com.android.tradefed.result.TestDescription, long)
for accurate measure.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
endTime |
long : the time the test ended, measured via System.currentTimeMillis() |
metrics |
: a ERROR(/Map) of the metrics emitted |
testEnded
public void testEnded (TestDescription testId,metrics)
Reports the execution end of an individual test case.
If testFailed(TestDescription, FailureDescription)
was not invoked, this test passed. Also returns any key/value
metrics which may have been emitted during the test case's execution.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
metrics |
: a ERROR(/Map) of the metrics emitted |
testFailed
public void testFailed (TestDescription testId, FailureDescription failure)
Reports the failure of a individual test case.
Will be called between testStarted and testEnded.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
failure |
FailureDescription : FailureDescription describing the failure and its context. |
testFailed
public void testFailed (TestDescription testId, String reason)
Reports the failure of a individual test case.
Will be called between testStarted and testEnded.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
reason |
String : stack trace of failure |
testIgnored
public void testIgnored (TestDescription testId)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
testLog
public void testLog (String dataName, LogDataType dataType, InputStreamSource dataStream)
Provides the associated log or debug data from the test invocation.
Must be called beforeERROR(/ITestInvocationListener#invocationFailed(Throwable))
or
ERROR(/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. |
testModuleEnded
public void testModuleEnded ()
Reports the end of a module run.
testModuleStarted
public void testModuleStarted (IInvocationContext moduleContext)
Reports the beginning of a module running. This callback is associated with testModuleEnded()
and is optional in the sequence. It is only used during a run that uses
modules: suite based runners.
Parameters | |
---|---|
moduleContext |
IInvocationContext : the IInvocationContext of the module. |
testRunEnded
public void testRunEnded (long time,runMetrics)
Reports end of test run.
Parameters | |
---|---|
time |
long : device reported elapsed time, in milliseconds |
runMetrics |
: key-value pairs reported at the end of a test run |
testRunFailed
public void testRunFailed (FailureDescription failure)
Reports test run failed to complete due to a failure described by FailureDescription
.
Parameters | |
---|---|
failure |
FailureDescription : FailureDescription describing the failure and its context. |
testRunFailed
public void testRunFailed (String reason)
Reports test run failed to complete due to a fatal error.
Parameters | |
---|---|
reason |
String : String describing reason for run failure. |
testRunStarted
public void testRunStarted (String runName, int testCount, int attemptNumber)
Reports the start of a test run.
Parameters | |
---|---|
runName |
String : the test run name |
testCount |
int : total number of tests in test run |
attemptNumber |
int : order number, identifying the different attempts of the same runName
that run multiple times. The attemptNumber is 0-indexed and should increment everytime
a new run happens. e.g. A test is granular retried 3 times, it should have 4 total
runs under the same runName and the attemptNumber is from 0 to 3. |
testRunStarted
public void testRunStarted (String runName, int testCount)
Reports the start of a test run.
Parameters | |
---|---|
runName |
String : the test run name |
testCount |
int : total number of tests in test run |
testRunStarted
public void testRunStarted (String runName, int testCount, int attemptNumber, long startTime)
Reports the start of a test run.
Parameters | |
---|---|
runName |
String : the test run name |
testCount |
int : total number of tests in test run |
attemptNumber |
int : order number, identifying the different attempts of the same runName
that run multiple times. The attemptNumber is 0-indexed and should increment everytime a
new run happens. e.g. A test is granular retried 3 times, it should have 4 total runs
under the same runName and the attemptNumber is from 0 to 3. |
startTime |
long : the time the run started, measured via System.currentTimeMillis() |
testRunStopped
public void testRunStopped (long arg0)
Reports test run stopped before completion due to a user request.
TODO: currently unused, consider removing
Parameters | |
---|---|
arg0 |
long : device reported elapsed time, in milliseconds |
testSkipped
public void testSkipped (TestDescription testId, SkipReason reason)
Called when a test is skipped and did not execute for a reason that is not usually expected. These tests will be attempted to be retried to attempt to get a proper execution.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
reason |
SkipReason : SkipReason |
testStarted
public void testStarted (TestDescription testId, long startTime)
Alternative to testStarted(com.android.tradefed.result.TestDescription)
where we also specify when the test was
started, combined with ERROR(/#testEnded(com.android.tradefed.result.TestDescription,long,Map))
for accurate measure.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |
startTime |
long : the time the test started, measured via System.currentTimeMillis() |
testStarted
public void testStarted (TestDescription testId)
Reports the start of an individual test case. Older interface, should use testStarted(com.android.tradefed.result.TestDescription)
whenever possible.
Parameters | |
---|---|
testId |
TestDescription : identifies the test |