How to add HTML report and logs to the Cucumber test automation framework (6/7)

Photo by Daniel Cheung — Unsplash

Add log4j2 and ExtentReports dependencies

First of all, add dependencies to the pom.xml file:

Add log4j2 configuration files

Configuration files for the log4j2 contains log message format, log file name and files rotation strategy.

Add log messages to the code

We will log events occurred in the ListenerPlugin. Create LOG object at the ListenerPlugin:

Implement TestReport

Reporting to the HTML will be used the same way as log messages. We will implement TestReport class which will be write messages and screenshots into the HTML report file.

Add additional methods to the listener

We need to add few method to the SeleniumDriverManager. All created drivers object will be added to the list, also last created driver will available via method getCurrentDriver.

Add report initialization

Add line below to the init method from the TestInitialization class:

Add request/response logging to the RestAssured

Also, we want to log all API requests and responses. To achivee it, we utilize filters functionalities from RestAssured. Open TestInitializer, add LOG object and filter implementation to the init method:

Execute the tests

Final version of a code is here.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store