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
Selected Reading
How will you run a prerequisite method and post condition method for\\nevery test in TestNG?
We can run a prerequisite method and post condition method for every test in TestNG with the help of @BeforeMethod and @AfterMethod annotations.
Example
@BeforeMethod
public void prerequisite(){
System.out.println("Run before every tests");
}
@AfterMethod
public void postcondition(){
System.out.println("Run after every tests ");
}
@Test
public void loanPay(){
System.out.println("Loan pay is successful");
}
In the Java class file, the prerequisite() method with @BeforeMethod will be executed which is known as the precondition for every test method. Then loanPay() will be executed and finally the postcondition() method with @AfterMethod will run.
Advertisements
