Hello everybody, today I am going to talk about Klov – ExtentReports reporting library by ExtentReports. As you may already know, ExtentReport provides great visual reporting to your Selenium tests. We talked about it in this article (http://www.swtestacademy.com/extentreports-testng/)  You might need to read this article to fully understand this article as I am not going into deep with TestNG and other configurations.

Extent Report team extended this library for historical reporting. Right now Extent Report is a web application using MongoDB and Spring Framework. Right now you can track your builds, their execution results aligned with it by using the web application.

I used Selenium with TestNG. So I will use TestNG listener to create my report. You may customize it for JUnit also. Here is the basic instruction to get started.

Installing Mongo DB and Run It

Installing is a straightforward process. I am using MacOS so my instruction might change in other OS.

Run Brew update and brew install mongodb command on your terminal. MongoDB is installed.

Right now, we need to run it. Type mkdir -p /data/db in terminal. By this way, you’ll create a folder for mongoDB to store its DB. In case you get a warning message mkdir: /data/db: Permission denied , just use sudo command as sudo mkdir -p /data/db.

Finally, run mongod command. You might once again receive an exception about writing, reading exceptions to the previously created folder. Mongod command tries to write and read from data/db folder by default. In case you have this exception, add sudo command as sudo mongod

For Windows installation of MongoDB please click here.

Run Your Klov – ExtentReports Application

Download your Klov-x-x-x.jar file from http://extentreports.com/community/ page. You’ll see Klov Download link at the bottom of the page. There are 2 files that are important to you:

  1. klov-x-x.jar file
  2. application.properties file.

You can run klov in the terminal with java -jar klov-x-x.jar command. You need to provide the right version.  In case you get an exception about port binding, go to application.properties file and change server.port value with an unbind port. (Note: On Windows please try to run java -jar klov-x-x.jar on the command prompt.)

Open Klov – ExtentReports Application

Go to http://localhost:portNo and if you see the welcome page. Everything is ready for Klov – Extentreports.

Modifying Your Selenium Test

First of all, there’s no need to change your test code. All you need to do is add a test listener into your project and Klov reporting basic Java code.

Test Base Code

I have added the basic code into my BeforeClass Annotation.

  • Create a KlovReporter object.
  • Define MongoDB connection
  • Give a project name to our test project
  • Define the build no as report name.
  • Set klov server URL
  • Finally, create an ExtentReports object and bind it to KlovReport object.

By doing so Klov will create a project with the given name. In case it exists, Klov will use the previously created project and store the results into it.

Test Listener Code

Test Listener base code is below. I create an ExtentTest object in the onTestStart method. So Klov – Extentreports starts to log this test.

Then after onTestSuccess, onTestFailute and onTestSkipped methods, I mark my test as pass, fail or skip.

Now run your tests and see the results like a charm in Klov Web Dashboard. You can check failures in historical view in timeline chart. You’ll see how many time you executed those tests and their build execution info.

Then you can check which tests are failing the most.

Finally, you can track the status with bar charts.

Sample Project Code is herehttps://github.com/swtestacademy/klov-extentreports-example

Happy testing!
Canberk Akduygu