This page describes the basics of how to implement a new result reporter and configure it for a test.
Core interface
In order to define a new result reporter in Tradefed, a class must implement
the
ITestInvocationListener
interface that allows receiving and handling different stages of the
invocation:
invocationStarted
invocationEnded
invocationFailed
Result reporters also handle the different stages of each test run:
testRunStarted
testStarted
testFailed
ortestIgnored
testEnded
testRunFailed
testRunEnded
Given all these events, there are two main types of result reporters, those that:
- Care only about reporting the final complete results.
- Take action on partial results.
Result reporter that reports final complete results
This type is the most common case when it comes to interacting with an external
service that receives the results. The reporter simply receives and accumulates
the results and then sends them all on invocationEnded
to the result end-point.
We recommend that those reporters extend CollectingTestListener
instead
of the base interface in order to avoid reimplementing saving and storing the
results until invocationEnded
.
Result reporter that reports partial results
This type is usually used for a streaming approach of the results, when results are received and pushed to some other places right away. For example, a reporter that logs the results to the console would be of this type.
This type is specific to which type of handling is required on the events, so implementing the base interface is usually the recommended way.
XML configuration
The object tag is result_reporter
. For example:
<result_reporter class="com.android.tradefed.result.ConsoleResultReporter">
<option name="suppress-passed-tests" value="true"/>
</result_reporter>