TestFailureListener

public class TestFailureListener
extends Object implements ITestInvocationListener

java.lang.Object
   ↳ com.android.tradefed.testtype.suite.TestFailureListener


Listener used to take action such as screenshot, bugreport, logcat collection upon a test failure when requested.

Summary

Public constructors

TestFailureListener(ITestInvocationListener listener, List<ITestDevice> devices, boolean bugReportOnFailure, boolean logcatOnFailure, boolean screenshotOnFailure, boolean rebootOnFailure, int maxLogcatBytes)

Public methods

void join()

Join on all the logcat capturing threads to ensure they terminate.

void testEnded(TestIdentifier test, Map<String, String> testMetrics)

Make sure we clean the map when test end to avoid too much overhead.

void testFailed(TestIdentifier test, String trace)

void testLog(String dataName, LogDataType dataType, InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

void testStarted(TestIdentifier test)

We override testStarted in order to track the start time.

Public constructors

TestFailureListener

TestFailureListener (ITestInvocationListener listener, 
                List<ITestDevice> devices, 
                boolean bugReportOnFailure, 
                boolean logcatOnFailure, 
                boolean screenshotOnFailure, 
                boolean rebootOnFailure, 
                int maxLogcatBytes)

Parameters
listener ITestInvocationListener

devices List

bugReportOnFailure boolean

logcatOnFailure boolean

screenshotOnFailure boolean

rebootOnFailure boolean

maxLogcatBytes int

Public methods

join

void join ()

Join on all the logcat capturing threads to ensure they terminate.

testEnded

void testEnded (TestIdentifier test, 
                Map<String, String> testMetrics)

Make sure we clean the map when test end to avoid too much overhead.

Parameters
test TestIdentifier

testMetrics Map

testFailed

void testFailed (TestIdentifier test, 
                String trace)

Parameters
test TestIdentifier

trace String

testLog

void testLog (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

Provides the associated log or debug data from the test invocation.

Must be called before invocationFailed(Throwable) or invocationEnded(long)

The TradeFederation framework will automatically call this method, providing the host log and if applicable, the device logcat.

Parameters
dataName String: a String descriptive name of the data. e.g. "device_logcat". Note dataName may not be unique per invocation. ie implementers must be able to handle multiple calls with same dataName

dataType LogDataType: the LogDataType of the data

dataStream InputStreamSource: the InputStreamSource of the data. Implementers should call createInputStream to start reading the data, and ensure to close the resulting InputStream when complete. Callers should ensure the source of the data remains present and accessible until the testLog method completes.

testStarted

void testStarted (TestIdentifier test)

We override testStarted in order to track the start time.

Parameters
test TestIdentifier