public class

EmailResultReporter

extends CollectingTestListener
implements ITestSummaryListener
java.lang.Object
   ↳ com.android.tradefed.result.CollectingTestListener
     ↳ com.android.tradefed.result.EmailResultReporter
Known Direct Subclasses

Class Overview

A simple result reporter base class that sends emails for test results.
Subclasses should determine whether an email needs to be sent, and can override other behavior.

Summary

Public Constructors
EmailResultReporter()
Protected Constructors
EmailResultReporter(IEmail mailer)
Create a EmailResultReporter with a custom IEmail instance to use.
Public Methods
void addDestination(String dest)
Adds an email destination address.
void invocationEnded(long elapsedTime)
Reports that the invocation has terminated, whether successfully or due to some error condition.
void invocationFailed(Throwable t)
Reports an incomplete invocation due to some error condition.
void putSummary(List<TestSummary> summaries)
Passes a List of non-null TestSummarys which may have been returned from any ITestInvocationListeners instantiated as part of the configuration.
Protected Methods
List<TestSummary> fetchSummaries()
Allow subclasses to get at the summaries we've received
String generateEmailBody()
A method to generate the body for email reports.
String generateEmailSubject()
A method to generate the subject for email reports.
Throwable getInvocationException()
Returns the Throwable passed via invocationFailed(Throwable).
InvocationStatus getInvocationStatus()
Returns the InvocationStatus
boolean isHtml()
void setHtml(boolean html)
A method to set a flag indicating that the email body is in HTML rather than plain text This method must be called before the email body is generated
boolean shouldSendMessage()
A method, meant to be overridden, which should do whatever filtering is decided and determine whether a notification email should be sent for the test results.
[Expand]
Inherited Methods
From class com.android.tradefed.result.CollectingTestListener
From class java.lang.Object
From interface com.android.ddmlib.testrunner.ITestRunListener
From interface com.android.tradefed.result.ITestInvocationListener
From interface com.android.tradefed.result.ITestSummaryListener

Public Constructors

public EmailResultReporter ()

Protected Constructors

protected EmailResultReporter (IEmail mailer)

Create a EmailResultReporter with a custom IEmail instance to use.

Exposed for unit testing.

Parameters
mailer the IEmail instance to use.

Public Methods

public void addDestination (String dest)

Adds an email destination address.

public 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 the elapsed time of the invocation in ms

public void invocationFailed (Throwable t)

Reports an incomplete invocation due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
t the Throwable cause of the failure

public void putSummary (List<TestSummary> summaries)

Passes a List of non-null TestSummarys which may have been returned from any ITestInvocationListeners instantiated as part of the configuration.

Parameters
summaries A List of non-null TestSummarys from ITestInvocationListeners that are part of the current configuration.

Protected Methods

protected List<TestSummary> fetchSummaries ()

Allow subclasses to get at the summaries we've received

protected String generateEmailBody ()

A method to generate the body for email reports. Will not be called if shouldSendMessage() returns false.

Returns
  • A String containing the body to use for an email report

protected String generateEmailSubject ()

A method to generate the subject for email reports. Will not be called if shouldSendMessage() returns false.

Returns
  • A String containing the subject to use for an email report

protected Throwable getInvocationException ()

Returns the Throwable passed via invocationFailed(Throwable).

protected InvocationStatus getInvocationStatus ()

Returns the InvocationStatus

protected boolean isHtml ()

protected void setHtml (boolean html)

A method to set a flag indicating that the email body is in HTML rather than plain text This method must be called before the email body is generated

Parameters
html true if the body is html

protected boolean shouldSendMessage ()

A method, meant to be overridden, which should do whatever filtering is decided and determine whether a notification email should be sent for the test results. Presumably, would consider how many (if any) tests failed, prior failures of the same tests, etc.

Returns
  • true if a notification email should be sent, false if not