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

Public constructors

TestRunResult()

Create an emptyTestRunResult.

Public methods

Set<TestDescription> getCompletedTests()

Gets the set of completed tests.

long getElapsedTime()

Returns the current run elapsed time.

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

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

String getRunFailureMessage()

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

Map<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()
Map<TestDescriptionTestResult> getTestResults()

Returns a map of the test results.

String getTextSummary()

Returns a user friendly string describing results.

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

Merge multiple TestRunResults of the same testRunName.

void setAggregateMetrics(boolean metricAggregation)
void setRunComplete(boolean runComplete)
void testAssumptionFailure(TestDescription test, String trace)
void testEnded(TestDescription test, HashMap<String, MetricMeasurement.Metric> testMetrics)
void testEnded(TestDescription test, long endTime, HashMap<String, MetricMeasurement.Metric> testMetrics)
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(String errorMessage)
void testRunStarted(String runName, int testCount)

Notify that a test run started.

void testRunStopped(long elapsedTime)
void testStarted(TestDescription test, long startTime)
void testStarted(TestDescription test)

Public constructors

TestRunResult

public TestRunResult ()

Create an emptyTestRunResult.

Public methods

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

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 (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

getRunLoggedFiles

public Map<String, LogFile> getRunLoggedFiles ()

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

Returns
Map<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.

getTestResults

public Map<TestDescriptionTestResult> getTestResults ()

Returns a map of the test results.

Returns
Map<TestDescriptionTestResult>

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)

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.

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

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

testEnded

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

Parameters
test TestDescription

testMetrics HashMap

testEnded

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

Parameters
test TestDescription

endTime long

testMetrics HashMap

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 (String errorMessage)

Parameters
errorMessage String

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 test cases associated with the test count.

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