Introduction

The EmailReporter creates an elegant, email-friendly report and support both BDD and non-BDD test styles. The email format is tested to work well with most major email clients and browsers.


Views

EmailReporter generates a single static HTML page without scripts or stylesheets. The static HTML page works well with all of the popular email clients.

Test

Usage


Initialize

Start and attach EmailReporter using attachReporter:

// directory where output is to be printed
ExtentEmailReporter email = new ExtentEmailReporter("user/build/name/");
ExtentReporter extent = new ExtentReports();
extent.attachReporter(email);

Configuration

EmailReporter supports a host of configuration via XML and Java.


XML

To load configuration via XML, use loadXMLConfig().

// using the file path
email.loadXMLConfig("email-config.xml");

// using java.io.File
email.loadXMLConfig(file);

The below XML configuration is available to EmailReporter.

<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
    <configuration>
        <!-- document encoding -->
        <!-- defaults to UTF-8 -->
        <encoding>UTF-8</encoding>

        <!-- title of the document -->
        <documentTitle>Extent Framework</documentTitle>
        
        <!-- report name - displayed at top-nav -->
        <reportName>Build 1</reportName>

		<!-- timestamp format -->
		<timeStampFormat>MMM dd, yyyy HH:mm:ss</timeStampFormat>

        <!-- custom styles -->
        <styles>
            <![CDATA[
                
            ]]>
        </styles>
    </configuration>
</extentreports>

Java

It is also possible to configure the reporter directly from code:

email.config().setAutoCreateRelativePathMedia(true);
email.config().setCSS("css-string");
email.config().setDocumentTitle("page title");
email.config().setEncoding("utf-8");
email.config().setReportName("build name");
email.config().setTimeStampFormat("MMM dd, yyyy HH:mm:ss");