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:
- Install and set up Java on your system.
- Now setup Eclipse.
- Launch Eclipse and create a Maven project.
- Add Selenium, TestNG, ExtentReport dependency in the pom.xml file.
ExtentReport dependency in our maven project, use the below snippet:-
Use Case in which we are going to mechanize
- Check the current URL of the web page
- Enter invalid email id in the Sign Up content box
- Click on the Sign Up button
- To verify the error message.
Create a Simple TestNG Script
Following is the code snippet for our use case.
- 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.
- assignAuthor(“AuthorName”) : Test case designer name is mentioned here.
- assignCategory(“CategoryName”) : Category of the Test Case displays here.
- log(LogStatus.PASS, “Step details”): It’s a repository which keeps the information about the test cases whether passed or failed.
- endTest(test) : Current test case ends here.
- flush() : Once the session is finished, specifically call the flush method.
- close() : Call this method at the very end in the @AfterSuite annotation, it ought to be called just once.
Following is the ‘extent-config.xml’ snippet.
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
After executing the test cases, the ExtentReport design will look like this.
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
- Open source reporting library.
- Provide delightful and responsive UI.
- Gives dashboard to the whole run.
- Exceptionally easy to utilize API.
- Effortlessly coordinate test-runner logs.
- Parallel execution of classes and strategies upheld.
- 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.