TestRunResult
public
class
TestRunResult
extends Object
implements
ITestRunListener
| java.lang.Object | |
| ↳ | com.android.ddmlib.testrunner.TestRunResult |
Holds results from a single test run.
Maintains an accurate count of tests, and tracks incomplete tests.
Not thread safe! The test* callbacks must be called in order
Summary
Public constructors | |
|---|---|
TestRunResult()
Create an empty |
|
Public methods | |
|---|---|
|
getCompletedTests()
Gets the set of completed tests. |
long
|
getElapsedTime()
Returns the current run elapsed time. |
String
|
getName()
|
int
|
getNumAllFailedTests()
Return total number of tests in a failure state (failed, assumption failure) |
int
|
getNumCompleteTests()
Gets the number of complete tests in this run ie with status != incomplete. |
int
|
getNumTests()
Gets the number of tests in this run. |
int
|
getNumTestsInState(TestResult.TestStatus status)
Gets the number of tests in given state for this run. |
String
|
getRunFailureMessage()
Return the run failure error message, |
|
getRunMetrics()
|
|
getTestResults()
Returns a map of the test results. |
String
|
getTextSummary()
Returns a user friendly string describing results. |
boolean
|
hasFailedTests()
|
boolean
|
isRunComplete()
|
boolean
|
isRunFailure()
|
void
|
setAggregateMetrics(boolean metricAggregation)
|
void
|
setRunComplete(boolean runComplete)
|
void
|
testAssumptionFailure(TestIdentifier test, String trace)
Called when an atomic test flags that it assumes a condition that is false |
void
|
testEnded(TestIdentifier test,
Reports the execution end of an individual test case. |
void
|
testFailed(TestIdentifier test, String trace)
Reports the failure of a individual test case. |
void
|
testIgnored(TestIdentifier test)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore. |
void
|
testRunEnded(long elapsedTime,
Reports end of test run. |
void
|
testRunFailed(String errorMessage)
Reports test run failed to complete due to a fatal error. |
void
|
testRunStarted(String runName, int testCount)
Reports the start of a test run. |
void
|
testRunStopped(long elapsedTime)
Reports test run stopped before completion due to a user request. |
void
|
testStarted(TestIdentifier test)
Reports the start of an individual test case. |
Public constructors
Public methods
getCompletedTests
publicgetCompletedTests ()
Gets the set of completed tests.
| Returns | |
|---|---|
|
|
getElapsedTime
public long getElapsedTime ()
Returns the current run elapsed time.
| Returns | |
|---|---|
long |
|
getName
public String getName ()
| Returns | |
|---|---|
String |
the test run name |
getNumAllFailedTests
public int getNumAllFailedTests ()
Return total number of tests in a failure state (failed, assumption failure)
| Returns | |
|---|---|
int |
|
getNumCompleteTests
public int getNumCompleteTests ()
Gets the number of complete tests in this run ie with status != incomplete.
| Returns | |
|---|---|
int |
|
getNumTests
public int getNumTests ()
Gets the number of tests in this run.
| Returns | |
|---|---|
int |
|
getNumTestsInState
public int getNumTestsInState (TestResult.TestStatus status)
Gets the number of tests in given state for this run.
| Parameters | |
|---|---|
status |
TestResult.TestStatus |
| Returns | |
|---|---|
int |
|
getRunFailureMessage
public String getRunFailureMessage ()
Return the run failure error message, null if run did not fail.
| Returns | |
|---|---|
String |
|
getTestResults
publicgetTestResults ()
Returns a map of the test results.
| Returns | |
|---|---|
|
|
getTextSummary
public String getTextSummary ()
Returns a user friendly string describing results.
| Returns | |
|---|---|
String |
|
hasFailedTests
public boolean hasFailedTests ()
| Returns | |
|---|---|
boolean |
true if test run had any failed or error tests. |
isRunComplete
public boolean isRunComplete ()
| Returns | |
|---|---|
boolean |
true if test run finished. |
isRunFailure
public boolean isRunFailure ()
| Returns | |
|---|---|
boolean |
true if test run failed. |
setAggregateMetrics
public void setAggregateMetrics (boolean metricAggregation)
| Parameters | |
|---|---|
metricAggregation |
boolean |
setRunComplete
public void setRunComplete (boolean runComplete)
| Parameters | |
|---|---|
runComplete |
boolean |
testAssumptionFailure
public void testAssumptionFailure (TestIdentifier test, String trace)
Called when an atomic test flags that it assumes a condition that is false
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
trace |
String: stack trace of failure |
testEnded
public void testEnded (TestIdentifier test,testMetrics)
Reports the execution end of an individual test case.
If testFailed(TestIdentifier, 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 |
TestIdentifier: identifies the test |
testMetrics |
: a ERROR(/Map) of the metrics emitted during the execution of the test case
by android.app.Instrumentation#sendStatus. The insertion order is preserved
unless you emit a same key multiple times. Note that standard keys defined in IInstrumentationResultParser.StatusKeys are filtered out of this Map. Ddmlib may add
extra test metrics defined in IInstrumentationResultParser.StatusKeys. |
testFailed
public void testFailed (TestIdentifier test, String trace)
Reports the failure of a individual test case.
Will be called between testStarted and testEnded.
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
trace |
String: stack trace of failure |
testIgnored
public void testIgnored (TestIdentifier test)
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |
testRunEnded
public void testRunEnded (long elapsedTime,
runMetrics) Reports end of test run.
| Parameters | |
|---|---|
elapsedTime |
long: device reported elapsed time, in milliseconds |
runMetrics |
: a ERROR(/Map) of the metrics emitted during the execution of the test case
by android.app.Instrumentation#addResults. The insertion order is preserved
unless you emit a same key multiple times. Note that standard keys defined in IInstrumentationResultParser.StatusKeys are filtered out of this Map. Ddmlib may add
extra test metrics defined in IInstrumentationResultParser.StatusKeys. |
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 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 |
testRunStopped
public void testRunStopped (long elapsedTime)
Reports test run stopped before completion due to a user request.
| Parameters | |
|---|---|
elapsedTime |
long: device reported elapsed time, in milliseconds |
testStarted
public void testStarted (TestIdentifier test)
Reports the start of an individual test case.
| Parameters | |
|---|---|
test |
TestIdentifier: identifies the test |