Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
How to incorporate and remove test methods from execution from ancollection of test cases in TestNG?
We can incorporate and remove test methods from execution with the
help of
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
