Serenity Emailable Report in Gradle

HOME

In this tutorial, I will generate an emailable Serenity Report for Gradle project. In the previous tutorial, I have explained the Generation of Serenity Emailable Report in Maven Project.

Pre-Requisite

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

This framework consists of:

  1. Serenity – 2.6.0
  2. Serenity Cucumber – 2.6.0
  3. Java 11
  4. JUnit – 4.13.2
  5. Gradle – 7.2

Steps to create Serenity Emailable Report

To setup a Gradle project for the testing of web application using Cucumber and JUnit4, please refer this tutorial (Step 1 to 3)

Update buildscript section of build.gradle file.

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath("net.serenity-bdd:serenity-gradle-plugin:2.4.24")
        classpath("net.serenity-bdd:serenity-single-page-report:2.4.24")
    }
}

Add serenity section in build.gradle.

serenity {
    reports = ["single-page-html"]
}

The complete build.gradle for the project will look like as shown below

defaultTasks 'clean', 'test', 'aggregate'

repositories {
    mavenLocal()
    jcenter()
}

buildscript {
    repositories {
        mavenLocal()
        jcenter()
    }
    dependencies {
        classpath("net.serenity-bdd:serenity-gradle-plugin:2.4.24")
        classpath("net.serenity-bdd:serenity-single-page-report:2.4.24")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'net.serenity-bdd.aggregator'

sourceCompatibility = 11
targetCompatibility = 11

serenity {
    reports = ["single-page-html"]
}

dependencies {
   
    testImplementation 'net.serenity-bdd:serenity-core:2.6.0'
    testImplementation 'net.serenity-bdd:serenity-cucumber6:2.6.0'
    testImplementation 'net.serenity-bdd:serenity-screenplay:2.6.0'
    testImplementation 'net.serenity-bdd:serenity-screenplay-webdriver:2.6.0'
    testImplementation 'junit:junit:4.13.1'
}

test {
    testLogging.showStandardStreams = true
    systemProperties System.getProperties()
}

gradle.startParameter.continueOnFailure = true

test.finalizedBy(aggregate)

Execute the test suite by using the below command.

gradle test

This will generate only index.html not serenity-summary.html (emailable) report.

To generate single page html report, we need to invoke the report task.

gradle reports

Below is the image of serenity-summary.html report.

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

Advertisement

4 thoughts on “Serenity Emailable Report in Gradle

  1. when i follow above steps i am not seeing emailable report in project. when i run :gradle reports i am getting this error: No report found on classpath with name single-page-html
    Serenity version: 2.4.24
    gradle version: 7.3.3

    Like

    1. I have used Serenity Version – 2.4.24 and gradle as 7.3.3 and able to generate the report. This is the build.gradle used by me.

      Are you using Java16/17?

      defaultTasks ‘clean’, ‘test’, ‘aggregate’

      repositories {
      mavenLocal()
      jcenter()
      }

      buildscript {
      repositories {
      mavenLocal()
      jcenter()
      }
      dependencies {
      classpath(“net.serenity-bdd:serenity-gradle-plugin:2.4.24”)
      classpath(“net.serenity-bdd:serenity-single-page-report:2.4.24”)
      }
      }

      apply plugin: ‘java’
      apply plugin: ‘eclipse’
      apply plugin: ‘idea’
      apply plugin: ‘net.serenity-bdd.aggregator’

      sourceCompatibility = 11
      targetCompatibility = 11

      serenity {
      reports = [“single-page-html”]
      }

      dependencies {

      testImplementation ‘net.serenity-bdd:serenity-core:2.4.24’
      testImplementation ‘net.serenity-bdd:serenity-cucumber6:2.4.24’
      testImplementation ‘net.serenity-bdd:serenity-screenplay:2.4.24’
      testImplementation ‘net.serenity-bdd:serenity-screenplay-webdriver:2.4.24’
      testImplementation ‘junit:junit:4.13.1’
      }

      test {
      testLogging.showStandardStreams = true
      systemProperties System.getProperties()
      }

      gradle.startParameter.continueOnFailure = true

      test.finalizedBy(aggregate)

      Like

  2. Serenity Emailable Report in Gradle — When I try to implement this code in my gradle multi project, It is generating in my main project not in sub project and also it is not considering sub project run, showing 0 run.. How to fix this could some one help me..

    Thank you,

    KTR

    Like

    1. You have made the changes for parent build.gradle, so it will generate the report for parent project only. To get this report for sub project, add it to sub project build.gradle too.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s