HTML Reporting using Extent Reporting
As an automation test engineer are supposed to test the application, find bugs and report it to the team in such a manner that they can easily understand the execution result.
The importance of Reporting:
In automation testing importance of reporting is so high.Reporting format varies from stage to stage.It may be category wise, types of testing involved or on an individual basis.Graphical representation using pie charts, table and graphs make the presentation of report better and easy to understand.
Extent Report is an HTML reporting library for Selenium WebDriver for Java which is a great degree simple to use and makes excellent execution reports. We can use this tool within our TestNG automation framework. As an automation tester its obligation to catch great reporting and present to the administration group.
Pre-Requisites for Extent Reporting:
- Java should be installed (Link to Install and setup Java )
- Maven should be installed (Link to Install and setup Maven )
- TestNG and Maven should be installed.
- Launch Eclipse and create a Maven Project.
- Add Selenium, TestNG, Extent Report dependency in the pom.xml file.
Extent Report Maven Dependency :
<!-- pom.xml --> <dependency> <groupId>com.relevantcodes</groupId> <artifactId>extentreports</artifactId> <version>2.41.1</version> </dependency>
Steps to Implement Extent HTML Reporting:
- Create a Sample Maven
- Add all the required dependencies to pom.xml file of your maven project.
- Convert the Maven project to TestNG. (Right Click on newly created project –> Proceed to “TestNG” –> Click on “Convert to TestNG”).
- Create a new class file (Driver.java) into src–>Test –> Java –> Package Name –> Driver.java
- Paste the below mentioned code to Driver.java file
Code Explanation :
ExtentReports(“filePath”,”replaceExisting”) : Provide Desired Report filepath Directory location name and Boolean settings to overwrite existing report file.
extent.loadConfig(new File(“extent-config.xml”)) : Supporting File for Extent Reporting which allows configuration of HTML Report. It helps us in customizing our report file.
extent.addSystemInfo(“Environment”,”Environment Name”) : Adding this to report will provide execution machine information.
test.startTest(“TestCaseName”, “Description”) : Description of the the Test Case on Report starts here.
- TestCaseName – The name of the test
- Description – A small depiction of the test
test.assignAuthor(“Author Name”): This will allocate the author name of the test script on theReport Dashboard.
test.assignCategory(“Category Name”): This will allocate the category to the test.
test.log(LogStatus.PASS, “Step details”): It helps us to assign the pass test steps to the report.
test.log(LogStatus.FAIL, “Step details”): It helps us to assign the fail test steps to the report.
endTest(test): It helps us to end and prepares the current test to be added to the HTML report.
flush(): Once the session is finished, it appends the HTML file with all the executed test cases.
close(): Call this method to close all the operation at the very end in the @AfterSuite annotation, it ought to be called just once.
How to view Extent Report:
When we open Extent Report, it comes in HTML Format containing 3 sections:
1. Dashboard: Overall Report of the Test Case
2. Category: Category wise Result
3. Tests: Individual Test Case Result
Dashboard Section or Overall Execution Report:
After successful execution of the test script, As you open the HTML report you will be redirected to Dashboard. It will display overall execution report status.
It will display category-wise execution report status.
Individual Test Case Result:
It will display individual execution report status.
GitHub Code Repository:-
Points of interest of Extent Report:
- It is an open source reporting library.
- Delightful and responsive UI.
- Gives dashboard containing information to the whole run.
- Effortlessly coordinate test-runner logs.
It’s a useful repository having an extraordinary Extent HTML report.Each association ought to utilize this report as the yield of the UI Automation is in an easy to use the report in which a nontechnical or management people can understand easily which test case is working appropriately and which is not.