Automated testing with Cucumber (Part 4) – How to create reports

Tram Ho

When you have to share the report of automatic runs, pass / fail results for customers and management, in that case you need an HTML report to share the results after each run. In this article I will guide how to setup with 1 HTML file after each run.

1. Create an HTML report by adding the plugin to the TestRunner file

(This method only creates a simple report, which case passes, which ones fail, the statistics of no / fail)

Step 1: In the TestRunner file, add a plugin (as below) to format the result after running into HTML format. You need a link to place the report file, here I have the path: target / htmlreports .

Step 2: Run the TestRunner file, when you are finished you will see the htmlreports folder in the target directory. To open the report, access the project that you already have on your computer and

Step 3: After running, a new folder will be created at the installation path in the plugin. Open the folder on the device (as shown below):

Here is the report after running:

  • When running the pass:
  • When running fail, it will be red in the step of fail failure and describe the error:

2. Create reports using Extent-Reports

Step 1: Add dependencies to pom.xml to update the project after adding

Step 2: Add a config folder to the project. (This way you can configure the name, interface, … of the report and detailed statistics of case pass / fail numbers)

For example: Right-click the project name -> Click New -> Folder -> config. Then, you create an XML file: report.xml into this directory, this file contains the title, name, report format, … You can configure the information you want in this file.

Step 3: Add a plugin to the TestRunner file to format the result after running into HTML format:

Step 4: Add a method to the AfterScenario function in the Hooks file

Step 5: After running, a new folder will be created at the path you install in the plugin. Open the folder on the device (as shown below):

  • When running the pass
  • When running fail

References: https://www.axelerant.com/resources/team-blog/setup-for-selenium-with-cucumber-using-maven

Share the news now

Source : Viblo