- 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
How does running a specific test method depend on another test method in TestNG?
The execution of a particular test method can be made dependent on another test method with the help of dependsOnMethods helper attribute.
Example
Code Implementation
@Test(dependsOnMethods={"Payment"}) public void verifyLoan(){ System.out.println("Loan payment successful"); } @Test public void Payment(){ System.out.println("Payment successful "); } @Test public verifyTransaction(){ System.out.println ("Transaction verification"); }
Here in the Java class file, verifyLoan() method will only be executed after the Payment() method is run successfully. But verifyTransaction() method runs independently without having a precondition test method to be executed.
Advertisements