How to set the order of execution for test methods in Cucumber?

CucumberSoftware TestingAutomation Testing

We can set the order of execution for test methods in Cucumber with the help of order keyword. Test methods are assigned with order in the step definition file.

The test method with lower order executes first followed by the methods with higher orders.

Example

Step definition file.

@Before (order = 1)
public void login(){
   System.out.println("login is successful");
}
@Before (order = 2)
public void payment(){
   System.out.println("payment is successful");
}
@Given ("^Land in repayment page$")
public void repay(){
   System.out.println ("Actual Scenario of repayment");
}

The test method with lower order (login() set to 1) will be executed first. Then payment () test method will be executed with a higher order.

Once these methods get executed successfully test method repay() will be executed.

raja
Published on 11-Jun-2020 16:37:55
Advertisements