HOME

In the previous tutorial, I have explained the Generation of Serenity Report (index.html) using Cucumber6 and JUnit. Index.html report that act both as test report and living documentation for the product. It has various views like Overall Test Status, Requirement View, Capabilities View and Features View.

Sometimes it is useful to be able to send a short summary of the test outcomes via email. Serenity allows us to generate a single-page, self-contained HTML summary report, containing an overview of the test results, and a configurable breakdown of the status of different areas of the application. 

Pre-Requisite

  1. Java 11 installed
  2. Maven installed
  3. Eclipse or IntelliJ installed

This framework consists of:

  1. Java 11
  2. Maven – 3.8.1
  3. Serenity – 2.6.0
  4. Serenity Maven – 2.6.0
  5. Serenity Cucumber6 – 2.6.0
  6. JUnit – 4.13.2
  7. Maven Surefire Plugin – 3.0.0-M5
  8. Maven Failsafe Plugin – 3.0.0-M5
  9. Maven Comiler Plugin - 3.8.1

Implementation Steps

  1. Update Properties section in Maven pom.xml
  2. Add repositories and pluginRepository to Maven pom.xml
  3. Add Serenity, Serenity Cucumber and JUnit dependencies to POM.xml
  4. Update Build Section of pom.xml
  5. Create source folder – src/test/resources and features folder within src/test/resources to create test scenarios in Feature file
  6. Create the Step Definition class or Glue Code
  7. Create a Serenity-Cucumber Runner class
  8. Create serenity.conf file under src/test/resources
  9. Create serenity.properties file in the root of the project
  10. Run the tests through commandline which generates Serenity Report

To know about Step 1 to 3, please refer here. These steps are same for Index.html report and emailable report.

Now, add the below mentioned plugin. These reports are configured in the Serenity Maven plugin, where you need to do two things. First, you need to add a dependency for the serenity-emailer module in the plugin configuration. Then, you need to tell Serenity to generate the email report when it performs the aggregation task.

 <plugin>     <groupId>net.serenity-bdd.maven.plugins</groupId>     <artifactId>serenity-maven-plugin</artifactId>     <version>${serenity.version}</version>     <dependencies>          <dependency>             <groupId>net.serenity-bdd</groupId>             <artifactId>serenity-single-page-report</artifactId>             <version>${serenity.version}</version>         </dependency>         <dependency>             <groupId>net.serenity-bdd</groupId>             <artifactId>serenity-navigator-report</artifactId>             <version>${serenity.version}</version>         </dependency>     </dependencies>     <configuration>         <tags>${tags}</tags>         <reports>single-page-html,navigator</reports>      </configuration>     <executions>         <execution>             <id>serenity-reports</id>             <phase>post-integration-test</phase>             <goals>                 <goal>aggregate</goal>             </goals>         </execution>     </executions> </plugin> 

Step 10 - Run the tests through commandline which generates Serenity Report

Open commandline and go to the location where pom.xml of the project is present and type the below command.

 mvn verify -Dwebdriver.gecko.driver="C:\\Users\\Vibha\\Software\\geckodriver-v0.26.0-win64\\geckodriver.exe" 

I have provided the location of firefoxdriver through commandline. I believe this is the best way to run the test. We can hard-code the path in the test code or in serenity.conf file. In that case, you don't need to provide location of firefoxdriver through command line. You can use below command.

 mvn verify 

This image show that two different type of reports are generated by Serenity - Full Report (index.html) and Single Page HTML Summary ( serenity-summary.html ).

This emailable report is called serenity-summary.html. This is generated under site/serenity/ serenity-summary.html

You can see a sample of such a report here:

As you can see in the above execution status, out of six tests, one test is failed. The same information is displayed in the report.

This report provides summary of the test execution.

The Functional Coverage section lets us highlight key areas of your application. By default, this section will list test results for each Feature. But we can configure the report to group results by other tags as well.

We are done! Congratulations on making it through this tutorial and hope you found it useful! Happy Learning!!


This post is ad-supported