{"id":37065,"date":"2016-06-29T16:10:13","date_gmt":"2016-06-29T10:40:13","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=37065"},"modified":"2017-05-25T10:50:51","modified_gmt":"2017-05-25T05:20:51","slug":"how-to-use-extentreport-in-a-framework-2","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/how-to-use-extentreport-in-a-framework-2\/","title":{"rendered":"How to use ExtentReport in a framework"},"content":{"rendered":"<p>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&#8217;t find its user interface very friendly especially when it&#8217;s about creating reports. That&#8217;s when I came across a user friendly reporting tool called\u00a0<strong>ExtentReport<\/strong>.<\/p>\n<p>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 <a title=\"automation testing engineers\" href=\"http:\/\/www.tothenew.com\/testing\/automated-independent-manual-testing\">an automation tester<\/a>, it\u2019s 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.<\/p>\n<p><strong>Process to Set up ExtentReport:<\/strong><\/p>\n<ol>\n<li>Install and set up Java on your system.<\/li>\n<li>Now setup Eclipse.<\/li>\n<li>Launch Eclipse and create a Maven project.<\/li>\n<li>Add Selenium, TestNG, ExtentReport dependency in the pom.xml file.<\/li>\n<\/ol>\n<p>ExtentReport dependency in our maven project, use the below snippet:-<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-37086\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/five.png\" alt=\"five\" width=\"561\" height=\"128\" \/><\/p>\n<p><strong>Use Case in which we are going to mechanize<\/strong><\/p>\n<ol>\n<li>Check the current URL of the web page<\/li>\n<li>Enter invalid email id in the Sign Up content box<\/li>\n<li>Click on the Sign Up button<\/li>\n<li>To verify the error message.<\/li>\n<\/ol>\n<p><strong>Create a Simple TestNG Script<\/strong><br \/>\nFollowing is the code snippet for our use case.<\/p>\n<p><strong><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-37048\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/one.png\" alt=\"one\" width=\"704\" height=\"624\" \/><\/strong><\/p>\n<ol>\n<li><strong>startTest(\u201cTestCaseName\u201d, \u201cDescription\u201d) : <\/strong>It starts the current test.<\/li>\n<\/ol>\n<p><strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 TestCaseName \u2013<\/strong> It will print the name of the Test Case in the Report.<br \/>\n<strong>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 Description \u2013 <\/strong>It will print the description of the Test case.<\/p>\n<ol start=\"2\">\n<li><strong>assignAuthor(\u201cAuthorName\u201d) : <\/strong>Test case designer name is mentioned here.<\/li>\n<li><strong>assignCategory(\u201cCategoryName\u201d) : <\/strong>Category of the Test Case displays here.<\/li>\n<li><strong>log(LogStatus.PASS, \u201cStep details\u201d): <\/strong>It&#8217;s a repository which keeps the information about the test cases whether passed or failed.<\/li>\n<li><strong>endTest(test) : <\/strong>Current test case ends here.<\/li>\n<li><strong>flush() :<\/strong> Once the session is finished, specifically call the flush method.<\/li>\n<li><strong>close() : <\/strong>Call this method at the very end in the @AfterSuite annotation, it ought to be called just once.<\/li>\n<\/ol>\n<p>Following is the &#8216;extent-config.xml&#8217; snippet.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-48746 size-full\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/extent-config4.png\" alt=\"extent-config\" width=\"722\" height=\"636\" srcset=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/extent-config4.png 722w, \/blog\/wp-ttn-blog\/uploads\/2016\/06\/extent-config4-300x264.png 300w, \/blog\/wp-ttn-blog\/uploads\/2016\/06\/extent-config4-624x549.png 624w\" sizes=\"(max-width: 722px) 100vw, 722px\" \/><\/p>\n<p>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.<br \/>\n<strong>For e.g.:<\/strong> The path of the report will be <strong>D:\\MyExtentReport.html<\/strong><\/p>\n<p><strong>ExtentReport Architecture<\/strong><br \/>\nAfter executing the test cases, the <strong>ExtentReport<\/strong> design will look like this.<\/p>\n<p><strong> \u00a0<img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-37066\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/two.png\" alt=\"two\" width=\"606\" height=\"343\" \/> <\/strong><\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-37067\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/three.png\" alt=\"three\" width=\"300\" height=\"201\" \/>\u00a0<img decoding=\"async\" loading=\"lazy\" class=\"alignnone  wp-image-37068\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/06\/four.png\" alt=\"four\" width=\"300\" height=\"201\" \/><\/p>\n<p>In this report, the main page is the dashboard where:-<\/p>\n<ul>\n<li>You can view the total number of test cases and test steps<\/li>\n<li>Start time and End time are displayed<\/li>\n<li>Number of test cases passed, failed, skipped, and so on information is provided<\/li>\n<li>Number of steps of test cases passed, failed, and so on data is given<\/li>\n<li>Pass Percentage of total number of test cases is given<\/li>\n<li>Category Name of the test cases is likewise shown on the dashboard.<\/li>\n<\/ul>\n<p>Clicking on the middle tab, I will be able to see the suite level information and its status (whether it\u2019s 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.<\/p>\n<p><strong>Points of interest of ExtentReport<\/strong><\/p>\n<ol>\n<li>Open source reporting library.<\/li>\n<li>Provide delightful and responsive UI.<\/li>\n<li>Gives dashboard to the whole run.<\/li>\n<li>Exceptionally easy to utilize API.<\/li>\n<li>Effortlessly coordinate test-runner logs.<\/li>\n<li>Parallel execution of classes and strategies upheld.<\/li>\n<li>It can also be configured on Jenkins server.<\/li>\n<\/ol>\n<p>It&#8217;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.<\/p>\n<p><strong>HAPPY TESTING!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8217;t find its user interface very friendly especially when it&#8217;s about creating reports. That&#8217;s when I came across a user friendly reporting tool called\u00a0ExtentReport. ExtentReport [&hellip;]<\/p>\n","protected":false},"author":107,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":303},"categories":[1818,1816],"tags":[1561,14,4844,1562],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/37065"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/107"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=37065"}],"version-history":[{"count":1,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/37065\/revisions"}],"predecessor-version":[{"id":52465,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/37065\/revisions\/52465"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=37065"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=37065"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=37065"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}