TextResultReporter

public class TextResultReporter
extends InvocationToJUnitResultForwarder implements ITestInvocationListener, ILogSaverListener

java.lang.Object
   ↳ com.android.tradefed.result.InvocationToJUnitResultForwarder
     ↳ com.android.tradefed.result.TextResultReporter


A test result reporter that forwards results to the JUnit text result printer.

Summary

Public constructors

TextResultReporter()

Creates a TextResultReporter.

Public methods

void setLogSaver(ILogSaver logSaver)

Set the ILogSaver to allow the implementor to save files.

void testAssumptionFailure(TestDescription testId, String trace)

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

void testEnded(TestDescription testId, HashMap<String, MetricMeasurement.Metric> metrics)

Overrides parent to explicitly print out test metrics.

void testFailed(TestDescription testId, String trace)

Overrides parent to explicitly print out failures.

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

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

void testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

Called when the test log is saved.

void testRunEnded(long elapsedTime, HashMap<String, MetricMeasurement.Metric> metrics)

Overrides parent to explicitly print out metrics.

Public constructors

TextResultReporter

public TextResultReporter ()

Creates a TextResultReporter.

Public methods

setLogSaver

public void setLogSaver (ILogSaver logSaver)

Set the ILogSaver to allow the implementor to save files.

Parameters
logSaver ILogSaver: the ILogSaver

testAssumptionFailure

public void testAssumptionFailure (TestDescription testId, 
                String trace)

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

Parameters
testId TestDescription: identifies the test

trace String: stack trace of failure

testEnded

public void testEnded (TestDescription testId, 
                HashMap<String, MetricMeasurement.Metric> metrics)

Overrides parent to explicitly print out test metrics.

Parameters
testId TestDescription: identifies the test

metrics HashMap: a ERROR(/Map) of the metrics emitted

testFailed

public void testFailed (TestDescription testId, 
                String trace)

Overrides parent to explicitly print out failures. The ResultPrinter relies on the runner calling "print" at end of test run to do this. Reports the failure of a individual test case.

Will be called between testStarted and testEnded.

Parameters
testId 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 ITestInvocationListener.invocationFailed(Throwable) or 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.

testLogSaved

public void testLogSaved (String dataName, 
                LogDataType dataType, 
                InputStreamSource dataStream, 
                LogFile logFile)

Called when the test log is saved.

Should be used in place of ITestLogger.testLog(String, LogDataType, InputStreamSource).

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.

logFile LogFile: the LogFile containing the meta data of the saved file.

testRunEnded

public void testRunEnded (long elapsedTime, 
                HashMap<String, MetricMeasurement.Metric> metrics)

Overrides parent to explicitly print out metrics.

Parameters
elapsedTime long: device reported elapsed time, in milliseconds

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