Was it helpful?

Question

How does the execution of a particular test method depend on other test methods in TestNG?

TestNGFrameworkSoftware TestingJava Programming

The execution of a particular test method can be made dependent on another test method with the help of dependsOnMethods helper attribute.

Example

@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.

raja
Published on 11-Jun-2020 15:59:24
Advertisements
Was it helpful?
Not affiliated with Tutorialspoint
scroll top