- 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.
- Related Articles
- How does the execution of a particular test method depend on other test\nmethods in TestNG?
- How does TestNG invoke a test method using multiple threads?
- How to skip a particular test method in TestNG?
- How to overlook a particular test method from execution in TestNG?
- How will you run a prerequisite method and post condition method for\nevery test in TestNG?
- How to get the name of a test method that was run in a TestNG teardown method?
- How to retrieve test method description in TestNG before and after execution?
- How to retrieve test method name in TestNG before and after execution?
- How to disable a TestNG test based on a condition?
- How to run test groups in TestNG?
- How to run multiple test cases using TestNG Test Suite in Selenium?
- JavaScript RegExp test() Method
- How to skip TestNG test at runtime?
- How to run multiple test classes in TestNG?
- How to set a Test in Postman with JavaScript Method?

Advertisements