ITestLifeCycleReceiver

public interface ITestLifeCycleReceiver

com.android.tradefed.result.ITestLifeCycleReceiver


Receives event notifications during instrumentation test runs.

Patterned after org.junit.runner.notification.RunListener

The sequence of calls will be:

  • testRunStarted
  • testStarted
  • [testFailed]
  • [testAssumptionFailure]
  • [testIgnored]
  • testEnded
  • ....
  • [testRunFailed]
  • testRunEnded

Summary

Public methods

default void testAssumptionFailure(TestDescription test, String trace)

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

default void testEnded(TestDescription test, long endTime, Map<String, String> testMetrics)

Alternative to testEnded(TestDescription, Map) where we can specify the end time directly.

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

Reports the execution end of an individual test case.

default void testEnded(TestDescription test, Map<String, String> testMetrics)

Reports the execution end of an individual test case.

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

Alternative to testEnded(TestDescription, Map) where we can specify the end time directly.

default void testFailed(TestDescription test, String trace)

Reports the failure of a individual test case.

default void testIgnored(TestDescription test)

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

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

Reports end of test run.

default void testRunEnded(long elapsedTimeMillis, Map<String, String> runMetrics)

Reports end of test run.

default void testRunFailed(String errorMessage)

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

default void testRunStarted(String runName, int testCount)

Reports the start of a test run.

default void testRunStopped(long elapsedTime)

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

default void testStarted(TestDescription test, long startTime)

Alternative to testStarted(TestDescription) where we also specify when the test was started, combined with testEnded(TestDescription, long, Map) for accurate measure.

default void testStarted(TestDescription test)

Reports the start of an individual test case.

Public methods

testAssumptionFailure

public void testAssumptionFailure (TestDescription test, 
                String trace)

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

Parameters
test TestDescription: identifies the test

trace String: stack trace of failure

testEnded

public void testEnded (TestDescription test, 
                long endTime, 
                Map<String, String> testMetrics)

Alternative to testEnded(TestDescription, Map) where we can specify the end time directly. Combine with testStarted(TestDescription, long) for accurate measure.

Parameters
test TestDescription: identifies the test

endTime long: the time the test ended, measured via System.currentTimeMillis()

testMetrics Map: a Map of the metrics emitted

testEnded

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

Reports the execution end of an individual test case.

If testFailed(TestDescription, 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 TestDescription: identifies the test

testMetrics HashMap: a Map of the metrics emitted

testEnded

public void testEnded (TestDescription test, 
                Map<String, String> testMetrics)

Reports the execution end of an individual test case.

If testFailed(TestDescription, 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 TestDescription: identifies the test

testMetrics Map: a Map of the metrics emitted

testEnded

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

Alternative to testEnded(TestDescription, Map) where we can specify the end time directly. Combine with testStarted(TestDescription, long) for accurate measure.

Parameters
test TestDescription: identifies the test

endTime long: the time the test ended, measured via System.currentTimeMillis()

testMetrics HashMap: a Map of the metrics emitted

testFailed

public void testFailed (TestDescription test, 
                String trace)

Reports the failure of a individual test case.

Will be called between testStarted and testEnded.

Parameters
test TestDescription: identifies the test

trace String: stack trace of failure

testIgnored

public void testIgnored (TestDescription test)

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

Parameters
test TestDescription: identifies the test

testRunEnded

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

Reports end of test run. FIXME: We cannot have two Map<> interfaces with different type, so we have to use HashMap here.

Parameters
elapsedTimeMillis long: device reported elapsed time, in milliseconds

runMetrics HashMap: key-value pairs reported at the end of a test run with MetricMeasurement.Metric.

testRunEnded

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

Reports end of test run.

Parameters
elapsedTimeMillis long: device reported elapsed time, in milliseconds

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

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.

TODO: currently unused, consider removing

Parameters
elapsedTime long: device reported elapsed time, in milliseconds

testStarted

public void testStarted (TestDescription test, 
                long startTime)

Alternative to testStarted(TestDescription) where we also specify when the test was started, combined with testEnded(TestDescription, long, Map) for accurate measure.

Parameters
test TestDescription: identifies the test

startTime long: the time the test started, measured via System.currentTimeMillis()

testStarted

public void testStarted (TestDescription test)

Reports the start of an individual test case. Older interface, should use testStarted(TestDescription) whenever possible.

Parameters
test TestDescription: identifies the test