TestRunResult


class TestRunResult : 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

This is an android-compatible copy of com.android.ddmlib.testrunner.TestRunResult.

Summary

Public functions

(Mutable)Set<TestIdentifier!>!

Gets the set of completed tests.

String!
Int

Return total number of tests in a failure state (failed, assumption failure)

Int

Gets the number of complete tests in this run ie with status != incomplete.

Int

Gets the number of tests in this run.

Int

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

String!

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

String!

Return a user friendly string describing results.

Boolean
Boolean
Unit
setAggregateMetrics(metricAggregation: Boolean)
Unit

Called when an atomic test flags that it assumes a condition that is false

Unit
testEnded(
    test: TestIdentifier!,
    testMetrics: (Mutable)Map<String!, String!>!
)

Reports the execution end of an individual test case.

Unit
testFailed(test: TestIdentifier!, trace: String!)

Reports the failure of a individual test case.

Unit

Called when a test will not be run, generally because a test method is annotated with org.junit.Ignore.

Unit
testRunEnded(elapsedTime: Long, runMetrics: (Mutable)Map<String!, String!>!)

Reports end of test run.

Unit
testRunFailed(errorMessage: String!)

Reports test run failed to complete due to a fatal error.

Unit
testRunStarted(runName: String!, testCount: Int)

Reports the start of a test run.

Unit
testRunStopped(elapsedTime: Long)

Reports test run stopped before completion due to a user request.

Unit

Reports the start of an individual test case.

Public constructors

Public functions

getCompletedTests

fun getCompletedTests(): (Mutable)Set<TestIdentifier!>!

Gets the set of completed tests.

getName

fun getName(): String!
Returns
String!

the test run name

getNumAllFailedTests

fun getNumAllFailedTests(): Int

Return total number of tests in a failure state (failed, assumption failure)

getNumCompleteTests

fun getNumCompleteTests(): Int

Gets the number of complete tests in this run ie with status != incomplete.

getNumTests

fun getNumTests(): Int

Gets the number of tests in this run.

getNumTestsInState

fun getNumTestsInState(status: TestResult.TestStatus!): Int

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

getRunFailureMessage

fun getRunFailureMessage(): String!

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

getTextSummary

fun getTextSummary(): String!

Return a user friendly string describing results.

Returns
String!

hasFailedTests

fun hasFailedTests(): Boolean
Returns
Boolean

true if test run had any failed or error tests.

isRunFailure

fun isRunFailure(): Boolean
Returns
Boolean

true if test run failed.

setAggregateMetrics

fun setAggregateMetrics(metricAggregation: Boolean): Unit

testAssumptionFailure

fun testAssumptionFailure(test: TestIdentifier!, trace: String!): Unit

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

fun testEnded(
    test: TestIdentifier!,
    testMetrics: (Mutable)Map<String!, String!>!
): Unit

Reports the execution end of an individual test case.

If testFailed 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: (Mutable)Map<String!, String!>!

a Map of the metrics emitted

testFailed

fun testFailed(test: TestIdentifier!, trace: String!): Unit

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

fun testIgnored(test: TestIdentifier!): Unit

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

fun testRunEnded(elapsedTime: Long, runMetrics: (Mutable)Map<String!, String!>!): Unit

Reports end of test run.

Parameters
elapsedTime: Long

device reported elapsed time, in milliseconds

runMetrics: (Mutable)Map<String!, String!>!

key-value pairs reported at the end of a test run

testRunFailed

fun testRunFailed(errorMessage: String!): Unit

Reports test run failed to complete due to a fatal error.

Parameters
errorMessage: String!

String describing reason for run failure.

testRunStarted

fun testRunStarted(runName: String!, testCount: Int): Unit

Reports the start of a test run.

Parameters
runName: String!

the test run name

testCount: Int

total number of tests in test run

testRunStopped

fun testRunStopped(elapsedTime: Long): Unit

Reports test run stopped before completion due to a user request.

TODO: currently unused, consider removing

Parameters
elapsedTime: Long

device reported elapsed time, in milliseconds

testStarted

fun testStarted(test: TestIdentifier!): Unit

Reports the start of an individual test case.

Parameters
test: TestIdentifier!

identifies the test

Public properties

elapsedTime

val elapsedTimeLong

isRunComplete

var isRunCompleteBoolean

runMetrics

val runMetrics: (Mutable)Map<String!, String!>!

testResults

val testResults: (Mutable)Map<TestIdentifier!, TestResult!>!