How to use ExtentReport in a framework

29 / Jun / 2016 by Kimi Agarwal 0 comments

The other day while I was executing my TestNG test cases in the Selenium WebDriver, all my test cases got executed, and the report also showed correctly. However, I usually don’t find its user interface very friendly especially when it’s about creating reports. That’s when I came across a user friendly reporting tool called ExtentReport.

ExtentReport is an HTML reporting library for Java, which can be used with Selenium WebDriver. We can use this tool within our TestNG automation framework. As an automation tester, it’s expected of you to provide detailed yet reports and present it to the administration group. ExtentReport is a simple to use tool to make excellent execution reports.

Process to Set up ExtentReport:

  1. Install and set up Java on your system.
  2. Now setup Eclipse.
  3. Launch Eclipse and create a Maven project.
  4. Add Selenium, TestNG, ExtentReport dependency in the pom.xml file.

ExtentReport dependency in our maven project, use the below snippet:-

five

Use Case in which we are going to mechanize

  1. Check the current URL of the web page
  2. Enter invalid email id in the Sign Up content box
  3. Click on the Sign Up button
  4. To verify the error message.

Create a Simple TestNG Script
Following is the code snippet for our use case.

one

  1. startTest(“TestCaseName”, “Description”) : It starts the current test.

            TestCaseName – It will print the name of the Test Case in the Report.
            Description – It will print the description of the Test case.

  1. assignAuthor(“AuthorName”) : Test case designer name is mentioned here.
  2. assignCategory(“CategoryName”) : Category of the Test Case displays here.
  3. log(LogStatus.PASS, “Step details”): It’s a repository which keeps the information about the test cases whether passed or failed.
  4. endTest(test) : Current test case ends here.
  5. flush() : Once the session is finished, specifically call the flush method.
  6. close() : Call this method at the very end in the @AfterSuite annotation, it ought to be called just once.

Once the test cases are run successfully, the report will be created under your folder. Now, go to the folder and view the .html report.
For e.g.: The path of the report will be D:\MyExtentReport.html

ExtentReport Architecture
After executing the test cases, the ExtentReport design will look like this.

 two

three four

In this report, the main page is the dashboard where:-

  • You can view the total number of test cases and test steps
  • Start time and End time are displayed
  • Number of test cases passed, failed, skipped, and so on information is provided
  • Number of steps of test cases passed, failed, and so on data is given
  • Pass Percentage of total number of test cases is given
  • Category Name of the test cases is likewise shown on the dashboard.

Clicking on the middle tab, I will be able to see the suite level information and its status (whether it’s pass or fail). On clicking the respective test case name, it will show the test case details: its start time, end time and execution time.

Points of interest of ExtentReport

  1. Open source reporting library.
  2. Provide delightful and responsive UI.
  3. Gives dashboard to the whole run.
  4. Exceptionally easy to utilize API.
  5. Effortlessly coordinate test-runner logs.
  6. Parallel execution of classes and strategies upheld.
  7. It can also be configured on Jenkins server.

It’s a useful storehouse having an extraordinary HTML reporting feature. Automation Testers ought to utilize this report because of its effective reporting by which anybody can understand easily which test case is working appropriately and which falls flat.

HAPPY TESTING!

FOUND THIS USEFUL? SHARE IT

Leave a comment -