0% found this document useful (0 votes)
6 views14 pages

07 - 03 - TestNG Report Generation in Selenium WebDriver

Uploaded by

minhtandragon29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views14 pages

07 - 03 - TestNG Report Generation in Selenium WebDriver

Uploaded by

minhtandragon29
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

RBVH/ENG1

TestNG Report Generation in


Selenium WebDriver
May-2019

1
RBVH/ENG1

Content
 Method-1: emailable-report.html
 Method-2: index.html
 Method-3: Reporter Class

2
Method-1: emailable-report.html

1.Click on option "emailable-report.html"


2.Click on option web browser

3
Method-1: emailable-report.html

The output report of testng will look like below if


both the classes are passed:

4
Method-1: emailable-report.html

Consider the scenario in where you are


intentionally failing the test case i.e. DemoB class.
Then convert both the classes into testng.xml suite
file and run it. Then the result will look like this. It
will show the failed test cases.
This is result for DemoB class:

5
Method-1: emailable-report.html

6
Method-2 index.html
1.Right click on the index.html from the project directory.
2.Select option open with web browser option. It will display the result in the following order

7
Method-2 index.html

8
Method-3 Reporter Class
Along with these report generated methods, you can use object.properties file to store
the system generated logs as well as user generated logs. But one of the simplest ways
to store log information in testing is using Reporter Class.

Reporter is a class present in TestNG. It provides 4 different methods to store log


information they are:
1.Reporter.log(String s);
2.Reporter.log(String s, Boolean logToStandardOut);
3.Reporter.log(String s, int level);
4.Reporter.log(String s, int level, Boolean logToStandardOut);

9
Example:
Create Two classes such as DemoA and DemoB and write the following code inside the classes.
For Class DemoA;
•The Code for DemoA is already explained above. Here you are using log method of Reporter class. (For
implementing a reporting class, the class has to implement an org.testng.IReporter interface).
•The log method is a static method of Reporter class. So you are accessing that method through the
Reporter class.
•The log method is used to store log information that is written inside the program. By looking at the log
information, you will easily come to know where exactly the execution of the program is stopped.

10
Example:

11
Example:

•Now, Create testng.xml file by selecting these two classes and


•Select run as and
•Click on the convert to testng.
•Then run this testng.xml file by selecting run as and select testng suite.
•Then refresh the project open the test-output folder.

12
Example:
Click on reporter output. It will open logging info whatever written in the test
methods.

13
RBVH/ENG1

Reference
 https://www.guru99.com/testng-report.html

14

You might also like