How to use Extent Reports in code?

To use Extent Reports in code, follow the following steps:

  1. Create ExtentReports and ExtentTest objects as extentReport and extentTest respectively.
  2. Instantiate the ExtentReports object: extentReport = new ExtentReports (System.getProperty("user.dir") +"/test-output/SampleReport.html", true);.
  3. Add other details and load the configuration file. The config file is optional:
       extentReport
.addSystemInfo("Host Name", "SampleHostName")
.addSystemInfo("Environment", "Demo")
.addSystemInfo("User Name", "Pinakin Chaubal");
extent.loadConfig(new
File(System.getProperty("user.dir")+"\extent-config.xml"));.
  1. Start the test using extentTest = extentReport.startTest("Test1");.
  2. Log the result using extentTest.log(LogStatus.PASS, "Test Case Create Invoice has Passed");.
  3. At the end of the test, insert extentReport.endTest(extentTest).
  4. At the end of the suite, insert extentReport.flush(); and extentReport.close();. Only after the flush command will data appear in the report. These should be in the final block.

There are eight statuses that can be output to the report: Error, Fail, Fatal, Info, Pass, Skip, Unknown, and Warning.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.154.208