HTML Reporting using Extent Reporting

HTML Reporting using Extent Reporting

1

 

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:

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:

  1. Create a Sample Maven
  2. Add all the required dependencies to pom.xml file of your maven project.
  3. Convert the Maven project to TestNG. (Right Click on newly created project –> Proceed to “TestNG” –> Click on “Convert to TestNG”).
  4. Create a new class file (Driver.java) into src–>Test –> Java –> Package Name –> Driver.java
  5. 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.

1

Category-wise Result:

It will display category-wise execution report status.

2

Individual Test Case Result:

It will display individual execution report status.

3

GitHub Code Repository:-

https://github.com/kkashyap1707/Extentreporting

Points of interest of Extent Report:

  1. It is an open source reporting library.
  2. Delightful and responsive UI.
  3. Gives dashboard containing information to the whole run.
  4. Effortlessly coordinate test-runner logs.

Conclusion :

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.

 

11 thoughts on “HTML Reporting using Extent Reporting

  • I have tried this but facing issues:
    [INFO] Scanning for projects…
    [INFO]
    [INFO] ————————————————————————
    [INFO] Building Sample 0.0.1-SNAPSHOT
    [INFO] ————————————————————————
    [INFO]
    [INFO] — maven-resources-plugin:2.6:resources (default-resources) @ Sample —
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory F:\Proj\Workspace\Sample\src\main\resources
    [INFO]
    [INFO] — maven-compiler-plugin:3.1:compile (default-compile) @ Sample —
    [INFO] Nothing to compile – all classes are up to date
    [INFO]
    [INFO] — maven-resources-plugin:2.6:testResources (default-testResources) @ Sample —
    [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] skip non existing resourceDirectory F:\Proj\Workspace\Sample\src\test\resources
    [INFO]
    [INFO] — maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Sample —
    [INFO] Changes detected – recompiling the module!
    [WARNING] File encoding has not been set, using platform encoding Cp1252, i.e. build is platform dependent!
    [INFO] Compiling 1 source file to F:\Proj\Workspace\Sample\target\test-classes
    [INFO] ————————————————————-
    [ERROR] COMPILATION ERROR :
    [INFO] ————————————————————-
    [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    [INFO] 1 error
    [INFO] ————————————————————-
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 2.254 s
    [INFO] Finished at: 2016-09-13T23:34:29+05:30
    [INFO] Final Memory: 13M/114M
    [INFO] ————————————————————————
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:testCompile (default-testCompile) on project Sample: Compilation failure
    [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException

    • On your Eclipse IDE,
      Go into Window > Preferences > Java > Installed JREs > and check your installed JREs.
      You should have an entry with a JDK there.
      Select the Execution Env as show below. Click OK
      Then Right-Click on your Project -> Maven -> Update Project

  • [INFO] Scanning for projects…
    [INFO] ————————————————————————
    [INFO] BUILD FAILURE
    [INFO] ————————————————————————
    [INFO] Total time: 0.078 s
    [INFO] Finished at: 2017-03-22T17:24:50+05:30
    [INFO] Final Memory: 5M/119M
    [INFO] ————————————————————————
    [ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

    hey please find the error.

    and if possible then please let me know how to make change in testng.xml file

  • Pingback: bulgari bijoux imitation
  • I am not able to generate extent report for parallel test execution.
    For sequential tests it works fine, but in case of parallel tests, logs are merged which each other and its hard to differentiate which log belongs to which test.
    I tried many approaches in Extent but still no luck.
    Would really appreciate if anyone can help me out.

    • For Parallel test execution report, we have to follow different approach then the mentioned above approach. I will post the parallel test report approach ASAP.

Leave a Reply

%d bloggers like this: