EmailResultReporter

public class EmailResultReporter
extends CollectingTestListener implements ITestSummaryListener

java.lang.Object
   ↳ com.android.tradefed.result.CollectingTestListener
     ↳ com.android.tradefed.result.EmailResultReporter
Known Direct Subclasses
DeviceUnavailEmailResultReporter An EmailResultReporter that will send email when invocation fails due to a device not available exception. 
FailureEmailResultReporter An EmailResultReporter that sends notifications if either a test failure or invocation failure occurred. 
InvocationFailureEmailResultReporter An EmailResultReporter that can also restrict notifications to just invocation failures. 
TestFailureEmailResultReporter An EmailResultReporter that can also restrict notifications to just test failures. 


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()

Create a 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).

String getInvocationOrTestStatus()
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.

Public constructors

EmailResultReporter

EmailResultReporter ()

Create a EmailResultReporter

Protected constructors

EmailResultReporter

EmailResultReporter (IEmail mailer)

Create a EmailResultReporter with a custom IEmail instance to use.

Exposed for unit testing.

Parameters
mailer IEmail: the IEmail instance to use.

Public methods

addDestination

void addDestination (String dest)

Adds an email destination address.

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

invocationFailed

void invocationFailed (Throwable t)

Reports an incomplete invocation due to some error condition.

Will be automatically called by the TradeFederation framework.

Parameters
t Throwable: the Throwable cause of the failure

putSummary

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 List: A List of non-null TestSummarys from ITestInvocationListeners that are part of the current configuration.

Protected methods

fetchSummaries

List<TestSummary> fetchSummaries ()

Allow subclasses to get at the summaries we've received

Returns
List<TestSummary>

generateEmailBody

String generateEmailBody ()

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

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

generateEmailSubject

String generateEmailSubject ()

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

Sample email subjects:

  • "Tradefed result for powerChromeFullSitesLocal on mantaray-user git_jb-mr1.1-release JDQ39: FAILED"
  • "Tradefed result for Monkey on build 25: FAILED"

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

getInvocationException

Throwable getInvocationException ()

Returns the Throwable passed via invocationFailed(Throwable).

Returns
Throwable

getInvocationOrTestStatus

String getInvocationOrTestStatus ()

Returns
String

getInvocationStatus

InvocationStatus getInvocationStatus ()

Returns the InvocationStatus

Returns
InvocationStatus

isHtml

boolean isHtml ()

Returns
boolean

setHtml

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 boolean: true if the body is html

shouldSendMessage

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
boolean true if a notification email should be sent, false if not