TestRunResult

public class TestRunResult
extends Object

java.lang.Object
   ↳ com.android.tradefed.result.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

Constants

String ERROR_DIVIDER

Public constructors

TestRunResult()

Create an emptyTestRunResult.

Public methods

void addTestResult(TestDescription test, TestResult testResult)
Set<TestDescription> getCompletedTests()

Gets the set of completed tests.

long getElapsedTime()

Returns the current run elapsed time.

int getExpectedTestCount()

Gets the number of test cases this TestRunResult expects to have.

Set<TestDescription> getFailedTests()

Gets the set of failed tests.

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(TestStatus status)

Gets the number of tests in given state for this run.

int getNumTestsInState(TestResult.TestStatus ddmlibStatus)

FOR COMPATIBILITY with older status.

Set<TestDescription> getPassedTests()

Gets the set of passed tests.

FailureDescription getRunFailureDescription()

Returns the run failure descriptor, null if run did not fail.

String getRunFailureMessage()

Return the run failure error message, null if run did not fail.

MultiMap<String, LogFile> getRunLoggedFiles()

Returns a copy of the map containing all the logged file associated with that test case.

Map<String, String> getRunMetrics()
HashMap<String, MetricMeasurement.Metric> getRunProtoMetrics()
long getStartTime()

Returns the start time of the first testRunStart call.

Map<TestDescriptionTestResult> getTestEntriesInState(Collection<TestStatus> statuses)

Gets the set of tests in given statuses.

Map<TestDescriptionTestResult> getTestResults()

Returns a map of the test results.

Set<TestDescription> getTestsInState(List<TestStatus> statuses)

Gets the set of tests in given statuses.

List<TestResult> getTestsResultsInState(TestStatus status)

Returns all the TestResult in a particular state.

String getTextSummary()

Returns a user friendly string describing results.

boolean hasFailedTests()
boolean isRunComplete()
boolean isRunFailure()
static TestRunResult merge(List<TestRunResult> testRunResults)
static TestRunResult merge(List<TestRunResult> testRunResults, MergeStrategy strategy)

Merge multiple TestRunResults of the same testRunName.

void resetRunFailure()

Reset the run failure status.

void setAggregateMetrics(boolean metricAggregation)
void setRunComplete(boolean runComplete)
void testAssumptionFailure(TestDescription test, String trace)
void testAssumptionFailure(TestDescription test, FailureDescription failure)
void testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)
void testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)
void testFailed(TestDescription test, FailureDescription failure)
void testFailed(TestDescription test, String trace)
void testIgnored(TestDescription test)
void testLogSaved(String dataName, LogFile logFile)

Information about a file being logged are stored and associated to the test case or test run in progress.

void testRunEnded(long elapsedTime, HashMap<String, MetricMeasurement.Metric> runMetrics)

New interface using the new proto metrics.

void testRunEnded(long elapsedTime, Map<String, String> runMetrics)
void testRunFailed(FailureDescription failureDescription)
void testRunFailed(String errorMessage)
void testRunStarted(String runName, int testCount, long startTime)

Notify that a test run started.

void testRunStarted(String runName, int testCount)

Notify that a test run started.

void testRunStopped(long elapsedTime)
void testSkipped(TestDescription test, SkipReason reason)
void testStarted(TestDescription test, long startTime)
void testStarted(TestDescription test)

Constants

ERROR_DIVIDER

public static final String ERROR_DIVIDER

Constant Value: " ====Next Error==== "

Public constructors

TestRunResult

public TestRunResult ()

Create an emptyTestRunResult.

Public methods

addTestResult

public void addTestResult (TestDescription test, 
                TestResult testResult)

Parameters
test TestDescription

testResult TestResult

getCompletedTests

public Set<TestDescription> getCompletedTests ()

Gets the set of completed tests.

Returns
Set<TestDescription>

getElapsedTime

public long getElapsedTime ()

Returns the current run elapsed time.

Returns
long

getExpectedTestCount

public int getExpectedTestCount ()

Gets the number of test cases this TestRunResult expects to have. The actual number may be less than the expected number due to test crashes. Normally, such a mismatch indicates a test run failure.

Returns
int

getFailedTests

public Set<TestDescription> getFailedTests ()

Gets the set of failed tests.

Returns
Set<TestDescription>

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 (TestStatus status)

Gets the number of tests in given state for this run.

Parameters
status TestStatus

Returns
int

getNumTestsInState

public int getNumTestsInState (TestResult.TestStatus ddmlibStatus)

FOR COMPATIBILITY with older status. Use getNumTestsInState(TestStatus) instead.

Parameters
ddmlibStatus TestResult.TestStatus

Returns
int

getPassedTests

public Set<TestDescription> getPassedTests ()

Gets the set of passed tests.

Returns
Set<TestDescription>

getRunFailureDescription

public FailureDescription getRunFailureDescription ()

Returns the run failure descriptor, null if run did not fail.

Returns
FailureDescription

getRunFailureMessage

public String getRunFailureMessage ()

Return the run failure error message, null if run did not fail.

Returns
String

getRunLoggedFiles

public MultiMap<String, LogFile> getRunLoggedFiles ()

Returns a copy of the map containing all the logged file associated with that test case.

Returns
MultiMap<String, LogFile>

getRunMetrics

public Map<String, String> getRunMetrics ()

Returns
Map<String, String> a Map of the test run metrics.

getRunProtoMetrics

public HashMap<String, MetricMeasurement.Metric> getRunProtoMetrics ()

Returns
HashMap<String, MetricMeasurement.Metric> a Map of the test run metrics with the new proto format.

getStartTime

public long getStartTime ()

Returns the start time of the first testRunStart call.

Returns
long

getTestEntriesInState

public Map<TestDescriptionTestResult> getTestEntriesInState (Collection<TestStatus> statuses)

Gets the set of tests in given statuses.

Parameters
statuses Collection

Returns
Map<TestDescriptionTestResult>

getTestResults

public Map<TestDescriptionTestResult> getTestResults ()

Returns a map of the test results.

Returns
Map<TestDescriptionTestResult>

getTestsInState

public Set<TestDescription> getTestsInState (List<TestStatus> statuses)

Gets the set of tests in given statuses.

Parameters
statuses List

Returns
Set<TestDescription>

getTestsResultsInState

public List<TestResult> getTestsResultsInState (TestStatus status)

Returns all the TestResult in a particular state.

Parameters
status TestStatus

Returns
List<TestResult>

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.

merge

public static TestRunResult merge (List<TestRunResult> testRunResults)

Parameters
testRunResults List

Returns
TestRunResult

merge

public static TestRunResult merge (List<TestRunResult> testRunResults, 
                MergeStrategy strategy)

Merge multiple TestRunResults of the same testRunName. If a testcase shows up in multiple TestRunResults but has different results (e.g. "boottest-device" runs three times with result FAIL-FAIL-PASS), we concatenate all the stack traces from the FAILED runs and trust the final run result for status, metrics, log files, start/end time.

Parameters
testRunResults List: A list of TestRunResult to merge.

strategy MergeStrategy: the merging strategy adopted for merging results.

Returns
TestRunResult the final TestRunResult containing the merged data from the testRunResults.

resetRunFailure

public void resetRunFailure ()

Reset the run failure status.

Resetting the run failure status is sometimes required when retrying. This should be done with care to avoid clearing a real failure.

setAggregateMetrics

public void setAggregateMetrics (boolean metricAggregation)

Parameters
metricAggregation boolean

setRunComplete

public void setRunComplete (boolean runComplete)

Parameters
runComplete boolean

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, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

Parameters
test TestDescription

endTime long

testMetrics HashMap

testEnded

public void testEnded (TestDescription test, 
                HashMap<String, MetricMeasurement.Metric> testMetrics)

Parameters
test TestDescription

testMetrics HashMap

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

testLogSaved

public void testLogSaved (String dataName, 
                LogFile logFile)

Information about a file being logged are stored and associated to the test case or test run in progress.

Parameters
dataName String: the name referencing the data.

logFile LogFile: The LogFile object representing where the object was saved and and information about it.

testRunEnded

public void testRunEnded (long elapsedTime, 
                HashMap<String, MetricMeasurement.Metric> runMetrics)

New interface using the new proto metrics.

Parameters
elapsedTime long

runMetrics HashMap

testRunEnded

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

Parameters
elapsedTime long

runMetrics Map

testRunFailed

public void testRunFailed (FailureDescription failureDescription)

Parameters
failureDescription FailureDescription

testRunFailed

public void testRunFailed (String errorMessage)

Parameters
errorMessage String

testRunStarted

public void testRunStarted (String runName, 
                int testCount, 
                long startTime)

Notify that a test run started.

Parameters
runName String: the name associated to the test run for tracking purpose.

testCount int: the number of expected test cases associated with the test run.

startTime long

testRunStarted

public void testRunStarted (String runName, 
                int testCount)

Notify that a test run started.

Parameters
runName String: the name associated to the test run for tracking purpose.

testCount int: the number of expected test cases associated with the test run.

testRunStopped

public void testRunStopped (long elapsedTime)

Parameters
elapsedTime long

testSkipped

public void testSkipped (TestDescription test, 
                SkipReason reason)

Parameters
test TestDescription

reason SkipReason

testStarted

public void testStarted (TestDescription test, 
                long startTime)

Parameters
test TestDescription

startTime long

testStarted

public void testStarted (TestDescription test)

Parameters
test TestDescription