Last updated on June 24th, 2018 at 12:49 am
In this post, we will see a very important and basic concept of TestNG : Understanding of TestNG.xml
You must aware about the hierarchy of testng.xml to implement many concept of testng. Let’s learn it:
I will generate a testng.xml for below hierarchy of project:
The generated testng.xml will be as below. I have added some extra tags for better understanding.
When we generate a testng.xml by default, it includes all methods annotated with @Test tag of a class. That is the reason you do not see <method> tag. I added <method> to make you understand about hierarchy of testng.xml in above xml.
There are five levels in a testng.xml as marked in red border in above image:
You can relate all above levels with Testing Methodologies as below:
A project is divided in to different Modules. Each module is divided in to multiple Test Scenarios. Each test scenario is divided in to multiple Test Cases. Since TestNG is a testing framework, it also allows you to organize your test as you do as a manual tester. You can categorized your automation suite in same way as you do in manual testing.
- Method : Test Cases
- Class : Test Scenarios
- Classes : Module Testing
- Test : Integration Testing
- Suite : System Testing
These level allows you to do extra setup for a test or module or suit. We will see more in upcoming posts, how knowledge of levels in testng.xml is going to help us.
A suite(Project) can have multiple Tests(Modules). A Test can have multiple Classes ( Please note here I am talking about <class> tag not <classes>. You can have only single <classes> tag in a <test> tag).
More about TestNG in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
Author: Amod Mahajan
My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning