Package com.android.ddmlib.testrunner
Class TestRunResult
- java.lang.Object
-
- com.android.ddmlib.testrunner.TestRunResult
-
- All Implemented Interfaces:
ITestRunListener
public class TestRunResult extends java.lang.Object implements ITestRunListener
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
-
-
Constructor Summary
Constructors Constructor Description TestRunResult()
Create an emptyTestRunResult
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Set<TestIdentifier>
getCompletedTests()
Gets the set of completed tests.long
getElapsedTime()
java.lang.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 !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.java.lang.String
getRunFailureMessage()
Return the run failure error message,null
if run did not fail.java.util.Map<java.lang.String,java.lang.String>
getRunMetrics()
java.util.Map<TestIdentifier,TestResult>
getTestResults()
Gets a map of the test results.java.lang.String
getTextSummary()
Return a user friendly string describing results.boolean
hasFailedTests()
boolean
isRunComplete()
boolean
isRunFailure()
void
setAggregateMetrics(boolean metricAggregation)
void
setRunComplete(boolean runComplete)
void
testAssumptionFailure(TestIdentifier test, java.lang.String trace)
Called when an atomic test flags that it assumes a condition that is falsevoid
testEnded(TestIdentifier test, java.util.Map<java.lang.String,java.lang.String> testMetrics)
Reports the execution end of an individual test case.void
testFailed(TestIdentifier test, java.lang.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, java.util.Map<java.lang.String,java.lang.String> runMetrics)
Reports end of test run.void
testRunFailed(java.lang.String errorMessage)
Reports test run failed to complete due to a fatal error.void
testRunStarted(java.lang.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.
-
-
-
Constructor Detail
-
TestRunResult
public TestRunResult()
Create an emptyTestRunResult
.
-
-
Method Detail
-
setAggregateMetrics
public void setAggregateMetrics(boolean metricAggregation)
-
getName
public java.lang.String getName()
- Returns:
- the test run name
-
getTestResults
public java.util.Map<TestIdentifier,TestResult> getTestResults()
Gets a map of the test results.- Returns:
-
getRunMetrics
public java.util.Map<java.lang.String,java.lang.String> getRunMetrics()
- Returns:
- a
Map
of the test test run metrics.
-
getCompletedTests
public java.util.Set<TestIdentifier> getCompletedTests()
Gets the set of completed tests.
-
isRunFailure
public boolean isRunFailure()
- Returns:
true
if test run failed.
-
isRunComplete
public boolean isRunComplete()
- Returns:
true
if test run finished.
-
setRunComplete
public void setRunComplete(boolean runComplete)
-
getNumTestsInState
public int getNumTestsInState(TestResult.TestStatus status)
Gets the number of tests in given state for this run.
-
getNumTests
public int getNumTests()
Gets the number of tests in this run.
-
getNumCompleteTests
public int getNumCompleteTests()
Gets the number of complete tests in this run ie with status != incomplete.
-
hasFailedTests
public boolean hasFailedTests()
- Returns:
true
if test run had any failed or error tests.
-
getNumAllFailedTests
public int getNumAllFailedTests()
Return total number of tests in a failure state (failed, assumption failure)
-
getElapsedTime
public long getElapsedTime()
- Returns:
-
getRunFailureMessage
public java.lang.String getRunFailureMessage()
Return the run failure error message,null
if run did not fail.
-
testRunStarted
public void testRunStarted(java.lang.String runName, int testCount)
Description copied from interface:ITestRunListener
Reports the start of a test run.- Specified by:
testRunStarted
in interfaceITestRunListener
- Parameters:
runName
- the test run nametestCount
- total number of tests in test run
-
testStarted
public void testStarted(TestIdentifier test)
Description copied from interface:ITestRunListener
Reports the start of an individual test case.- Specified by:
testStarted
in interfaceITestRunListener
- Parameters:
test
- identifies the test
-
testFailed
public void testFailed(TestIdentifier test, java.lang.String trace)
Description copied from interface:ITestRunListener
Reports the failure of a individual test case.Will be called between testStarted and testEnded.
- Specified by:
testFailed
in interfaceITestRunListener
- Parameters:
test
- identifies the testtrace
- stack trace of failure
-
testAssumptionFailure
public void testAssumptionFailure(TestIdentifier test, java.lang.String trace)
Description copied from interface:ITestRunListener
Called when an atomic test flags that it assumes a condition that is false- Specified by:
testAssumptionFailure
in interfaceITestRunListener
- Parameters:
test
- identifies the testtrace
- stack trace of failure
-
testIgnored
public void testIgnored(TestIdentifier test)
Description copied from interface:ITestRunListener
Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.- Specified by:
testIgnored
in interfaceITestRunListener
- Parameters:
test
- identifies the test
-
testEnded
public void testEnded(TestIdentifier test, java.util.Map<java.lang.String,java.lang.String> testMetrics)
Description copied from interface:ITestRunListener
Reports the execution end of an individual test case.If
ITestRunListener.testFailed(com.android.ddmlib.testrunner.TestIdentifier, java.lang.String)
was not invoked, this test passed. Also returns any key/value metrics which may have been emitted during the test case's execution.- Specified by:
testEnded
in interfaceITestRunListener
- Parameters:
test
- identifies the testtestMetrics
- aMap
of the metrics emitted
-
testRunFailed
public void testRunFailed(java.lang.String errorMessage)
Description copied from interface:ITestRunListener
Reports test run failed to complete due to a fatal error.- Specified by:
testRunFailed
in interfaceITestRunListener
- Parameters:
errorMessage
-String
describing reason for run failure.
-
testRunStopped
public void testRunStopped(long elapsedTime)
Description copied from interface:ITestRunListener
Reports test run stopped before completion due to a user request.TODO: currently unused, consider removing
- Specified by:
testRunStopped
in interfaceITestRunListener
- Parameters:
elapsedTime
- device reported elapsed time, in milliseconds
-
testRunEnded
public void testRunEnded(long elapsedTime, java.util.Map<java.lang.String,java.lang.String> runMetrics)
Description copied from interface:ITestRunListener
Reports end of test run.- Specified by:
testRunEnded
in interfaceITestRunListener
- Parameters:
elapsedTime
- device reported elapsed time, in millisecondsrunMetrics
- key-value pairs reported at the end of a test run
-
getTextSummary
public java.lang.String getTextSummary()
Return a user friendly string describing results.- Returns:
-
-