XmlResultReporter

public class XmlResultReporter
extends CollectingTestListener implements ILogSaverListener

java.lang.Object
   ↳ com.android.tradefed.result.CollectingTestListener
     ↳ com.android.tradefed.result.XmlResultReporter


Writes JUnit results to an XML files in a format consistent with Ant's XMLJUnitResultFormatter.

Unlike Ant's formatter, this class does not report the execution time of tests.

Collects all test info in memory, then dumps to file when invocation is complete.

Ported from dalvik runner XmlReportPrinter.

Result files will be stored in path constructed via [--output-file-path]/[build_id]

Summary

Public constructors

XmlResultReporter()

Public methods

void invocationEnded(long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

void setLogSaver(ILogSaver logSaver)

Set the ILogSaver to allow the implementor to save files.

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 testLogSaved(String dataName, LogDataType dataType, InputStreamSource dataStream, LogFile logFile)

Called when the test log is saved.

Public constructors

XmlResultReporter

XmlResultReporter ()

Public methods

invocationEnded

void invocationEnded (long elapsedTime)

Reports that the invocation has terminated, whether successfully or due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
elapsedTime long: the elapsed time of the invocation in ms

setLogSaver

void setLogSaver (ILogSaver logSaver)

Set the ILogSaver to allow the implementor to save files.

Parameters
logSaver ILogSaver: the ILogSaver

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.

testLogSaved

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

Called when the test log is saved.

Should be used in place of 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.