Prettier HTML Reports for Cucumber-JVM

I work a fair bit with Cucumber-JVM in my professional life, which runs various acceptance / component tests for Java services. When sharing test results with stakeholders such as Product Owners, I need an easier format to share with them, so have used the built-in Cucumber html reporting:

Built-in HTML report

Late last year, Tim Norris recommended I try out the Jenkins plugin cucumber-reports-plugin for reporting instead of the built-in HTML reporter. He's been using it for some of the services that he owns, and found that the use of the plugin made looking at test results much easier than using the built-in reporting, not least because it was a bit more visual in its usage.

As we can see, it has a much nicer visual breakdown of the steps and features:

Pretty HTML report

All the plugin needs is to be pointed to your cucumber-report.json, after which it'll publish the HTML to the Jenkins UI.

However, the issue with this plugin is that it does this purely through Jenkins, not through the actual Cucumber test run. This means that in your i.e. target/ directory after a local build you won't get these pretty HTML reports, nor will you be able to easily download them through the Jenkins UI.

As I started to write a feature request on the cucumber-reporting project, which is the core library that cucumber-reports-plugin uses, I realised I should be a good Open Source citizen and take a look at the code first.

I couldn't seem to find anything that implemented the Cucumber Formatter, which would allow me hook it into the @CucumberOptions like so:

@CucumberOptions(plugin = {"pretty", "json:target/report.json", "cucumber-reporting:target/pretty-cucumber"}, features = {"classpath:features"})

But searching through the issues on the repo led me to the issue Is it possible to use cucumber-reporting plugin through cucumber CLI Runner? in which GitHub user monochromata mentioned that they had written cucumber-reporting-plugin to handle this.

This means it's really easy to run:

@CucumberOptions(plugin = {"pretty", "json:target/report.json", "de.monochromata.cucumber.report.PrettyReports:target/pretty-cucumber"}, features = {"classpath:features"})

Now, running Cucumber will generate a pretty report, which we can then view locally or archive within Jenkins, which look pretty great.

This saved me having to write my own wrapper to handle this, so thanks for the work on it! Hopefully it'll make it upstream to cucumber-reporting soon.

Update: The library now also supports Cucumber v4 as per my Merge Request Upgrade plugin to work with Cucumber v4.

Written by Jamie Tanna's profile image Jamie Tanna on , and last updated on .

Content for this article is shared under the terms of the Creative Commons Attribution Non Commercial Share Alike 4.0 International, and code is shared under the Apache License 2.0.

Tags
Related Posts

Other posts you may be interested in:

Interactions with this post

Interactions with this post

Below you can find the interactions that this page has had using WebMention.

Have you written a response to this post? Let me know the URL:

Do you not have a website set up with WebMention capabilities? You can use Comment Parade.