Selenium testng.xml and emailable report in detail

To get started with testNG framework, refer testNG framework If we want to execute the testng class, we can do one by one in eclipse by clicking F5 or right click run as,

what if we want to run multiple classes, then we can take use of testng.xml.

tetng.xml helps to execute one or more testNG classes at a time and also gives an option to maintain the sequence of execution of java classes and also it provides various ways to control the execution.

Let’s discuss them one by one.

To understand the testng.xml, let’s create some testng classes (by Right click on the project, select New -> “TestNG class”)



For this above classes, we will see the basic testng.xml execution:
Note: we can have some other name than testng.xml, like can have testng_regression.xml

Let’s understand the above xml before running….

  • suite name can be anything.
  • parallel attribute is set to none, as we want to run this suite once, when we want to run multiple times in different browser, we can set this attribute. please refer cross browser testing.
  • test name can be anything, enter a name such that it relates to your purpose.
  • preserve-order is set to false, if we want to run the mentioned classes in an unpredictable manner, if want to run in a sequence they are written, update the value to true.
  • in one test tag, we can have multiple classes, and each class can have multiple methods, if no method tag present under class tag, then all the methods of that class will be executed.
  • class name should be exactly same as  packageName.className

If we want to run all the classes of a package, no need to mention all the classes of that package under test tag, can have a package tag as mentioned below:

Run any one of the above testng.xml
[Refer my prev blog, for different ways of running testng.xml]
Output will be:

The output clearly says that, total 3 tests run in which 1 skipped, 1 failed, and 1 successfully executed.
To get more detailed report about the test execution, let’s see the test-output folder
(As created under project folder, if not appears, right click on the project and refresh)
Expand the test-output folder in Eclipse and open the index.html in browser
(Right click on the index.html,select ‘Open with’ -> Web browser)

Another kind of report called as (emailable-report.html), which you might be interested to look at.

Even you can navigate to your project folder (system explorer window) and can open these above 2 html files in any one your available browser (Chrome, Firefox or IE) to view more clearly.

Let’s get to know more about testNG, that is testNG annotations

Content posted is based on learning or working experience,
Share the post with others if find useful,
Any queries?, leave comments or discuss on our, Thanks!

1 Response

  1. May 4, 2016

    […] selenium testNGxml […]

Leave a Reply

Your email address will not be published. Required fields are marked *