Search code examples
javaselenium-webdrivertestngextentreports

Generate extent report using "ITestListener" or "IReporter" listeners


I need to generate a testng extent report (version 3). I saw that there are two ways to generate an extent report.

Here, I am explaining two cases without using the code.

  • Case 1:

    Creating a class implementing "IReporter" listener and this class is defined in the testng.xml file.

  • Case 2:

    Creating a java class (ExtentTestManager.java) and defined relavent methods, used "com.relevantcodes.extentreports.ExtentTest" and "com.relevantcodes.extentreports.ExtentReports" packages for implementation the logics.

Then, creating a class (TestListener) implementing "ITestListener" listener and extending BaseTest Class.

To override methods, this class is used the methods in ExtentTestManager.java class. Finally, this new class is defined testng.xml file.

Here, I want to know which implementation is appropriate to generate an extent report and reasons, please.

In case 2, why should be "TestListener" class extended the "TestBase" class as well?.


Solution

  • I found the answer for this question. Please refer this article.

    https://medium.com/extent-report-3-1-5-itestlistener-implementation/extent-report-is-widely-used-as-html-report-for-selenium-test-scripts-reason-being-simple-its-3f19214b2e19