I wish to change the CSS and logos in Serenity reports. Also I want to add some custom text or links to some tests in the Serenity reports.Like there is an excel report gets generated and I wish to provide a link of it in the test step in the report. What is the best way to achieve this?
I found a better and cleaner way to customise the Serenity reports. Basically, we can generate our own Serenity-reports-resources project with a different version number and configure our project to use our customised reports resources build instead of the official reports resources. The setps to do this are as follows:
Download sources from:
https://github.com/serenity-bdd/serenity-core.git
Modify build Gradle settings to generate your own "serenity-report-resources" jar file. Open the "build.gradle" file. 2.1 Add "mavenLocal()" to the repositories:
buildscript {
repositories {
mavenLocal()
.....
2.2 Add Maven publish plugin
apply plugin: 'maven-publish'
2.3 Change the subproject version number. Replace the line:
version = rootProject.version
for
version = '0.0.0.1'
Note: use the version number that you want in order to track changes of your reporting site.
Run
mvn clean build
for the subproject "serenity-report-resources"
3.1 Run
publishing / publishToMavenLocal
to install your reporting site as a new maven dependency in the local repository. Publish or deploy this build where you need it when running test in other environments.Configure your project to not include the official "serenity-report-resources" dependency and add yours instead.
4.1 In the dependencies section add the serenity-core without the reports.
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<exclusions>
<exclusion>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
</exclusion>
</exclusions>
</dependency>
4.2 Add your custom reports dependency. Use the same version number that you used before.
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
<version>0.0.0.1</version>
</dependency>
4.3 Configure the serenity plugin dependencies to use your custom reports build.
<!-- Serenity plugin -->
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.maven.version}</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
<exclusions>
<exclusion>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-report-resources</artifactId>
<version>0.0.2</version>
</dependency>
</dependencies>
<executions>
<execution>
<id>serenity-reports</id>
<phase>post-integration-test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
Now when you run tests with the "SerenityRunner" it should find the resources of your custom reports build instead of the official serenity reports build.
It would be better if we could just configure the location of resources needed to generate reports as static or system property from the same framework. Let see what I can do :-)
I hope it helps, Keep on hacking
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With