The right way is to use custom formatter (Plugins)
So what does this means ?
We are going to create our own report plugin using Extent report.
As in TestNG reporting, where we override the TestNG listeners to tell TestNG what to do for each action or events,
Here, we implements Cucumber listener class to listen to cucumber events and tell it what to do for each event.
Cucumber sends events for each action like scenario started, step started, step finished etc to this instance of the listener. So here we handle these events and tell cucumber what to do with these events (In our case we will tell it to log it to extent report).
There are two listener interfaces:
- EventListener
- ConcurrentEventListener
So as the name suggests, concurrentEventListener is thread-safe and the other is not. The implementation is exactly the same so we will use only the concurrentEventListner so that our framework is threadsafe when we have to run things in parallel.
Our TestListener :
package cucumberHooks;import com.aventstack.extentreports.ExtentReports;import…