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
- Java 11 installed
- Gradle installed
- Eclipse or IntelliJ installed
This framework consists of:
- Serenity – 2.6.0
- Serenity Cucumber – 2.6.0
- Java 11
- JUnit – 4.13.2
- 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!!