- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is a TestNG xml file in TestNG?
The testng.xml file has the numerous uses as listed below −
Test cases are executed in groups.
Test methods can be included or excluded in the execution.
The execution of multiple test cases from multiple java class files can be triggered.
Comprises names of the folder, class, method.
Capable of triggering parallel execution.
Test methods belonging to groups can be included or excluded in the execution.
Example
Code implementation of TestNG.xml file
<?xml version = "1.0" encoding = "UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name = "Cycle1"> <test name = "Tutorialspoint"> <classes> <class name = "Test1" /> <methods> <exclude name= “Login.*”/> </methods> </classes> </test> </suite>
Here as per the xml file, all the test methods with starting name Login will be excluded from test execution.
@Test public void VerifyPay(){ System.out.println("Verify payment is successful”); } @Test public void LoginAdmin(){ System.out.println("Login is successful in admin”); } @Test public void LoginSystem(){ System.out.println("Login is successful”); }
Here as per the java class file, only VerifyPay() will be executed since all methods starting with the name Login will be excluded from test execution.
- Related Articles
- What is TestNG Annotation Order?
- What are the annotations in TestNG?
- Is TestNG part of selenium?
- What exactly does a Thread count do in TestNG?
- What is the order of execution of tests in TestNG?
- What is the difference between selenium WebDriver and TestNG?
- What is the order of execution of TestNG methods?
- What do you mean by timeOut in TestNG?
- What do you mean by Listeners in TestNG?
- What is the order of test execution with priority in TestNG?
- What is the priority of BeforeClass and BeforeTest methods in TestNG?
- Difference between JUnit and TestNG
- How to use TestNG SkipException?
- Name the various annotations available in TestNG.
- How to achieve parallel execution in TestNG?

Advertisements