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( devices, boolean bugReportOnFailure, boolean rebootOnFailure)

Public methods

void applyModuleConfiguration(boolean bugreportOnFailure)

Allows to override the invocation settings of capture on failure by the module specific configurations.

void join()

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

void setLogger(ITestLogger logger)

Sets where the logs should be saved.

void testFailed(TestDescription test, String trace)

Reports the failure of a individual test case.

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

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

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

Forward the log to the logger, do not do it from whitin the #testLog callback as if TestFailureListener is part of the chain, it will results in an infinite loop.

Public constructors

TestFailureListener

public TestFailureListener ( devices, 
                boolean bugReportOnFailure, 
                boolean rebootOnFailure)

Parameters
devices

bugReportOnFailure boolean

rebootOnFailure boolean

Public methods

applyModuleConfiguration

public void applyModuleConfiguration (boolean bugreportOnFailure)

Allows to override the invocation settings of capture on failure by the module specific configurations.

Parameters
bugreportOnFailure boolean: true to capture a bugreport on test failure. False otherwise.

join

public void join ()

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

setLogger

public void setLogger (ITestLogger logger)

Sets where the logs should be saved.

Parameters
logger ITestLogger

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

testLog

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

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

Must be called before ERROR(/ITestInvocationListener#invocationFailed(Throwable)) or ERROR(/ITestInvocationListener#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.

testLogForward

public void testLogForward (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream)

Forward the log to the logger, do not do it from whitin the #testLog callback as if TestFailureListener is part of the chain, it will results in an infinite loop.

Parameters
dataName String

dataType LogDataType

dataStream InputStreamSource