![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
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
How to incorporate and remove test methods from execution from a
collection of test cases in TestNG?
We can incorporate and remove test methods from execution with the help of <groups> tags in testng xml file.
Example
Testng xml file.
<?xml version = "1.0" encoding = "UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" > <suite name = "Tutorialspoint Test "> <test name = "Test Cycle"> <groups> <run> <include name = "Smoke"/> <exclude name = "CodingModule"/> </run> </groups> <classes> <class name = "TestRegularExpression" /> </classes> </test> </suite>
The testNG xml has groups Smoke to be included and CodingModule to be excluded from the execution.
Example
@Test(groups={"Smoke"}) public void ContactDetails(){ System.out.println(“Contact details verification is successful”); } @Test(groups={"CodingModule"}) public void verifyInvoice(){ System.out.println(“Invoice verification is successful”); }
In a Java class file, groups are used to pinpoint the test method. The test methods with groups as Smoke will be added in the run and CodingModule will be excluded from execution. So ContactDetails() test method shall run but verifyInvoice() shall be left out from execution.
Advertisements