如何在黄瓜中运行前提条件和前提条件测试方法?
示例
功能文件。
Feature: Transaction Table Scenario: Verify the monthly transactions Given User is on the Payment Page
步骤定义具有带有钩子@Before和@After的方法。带有钩子@Before的测试方法将作为前提条件执行,然后将运行测试方法(naviagteToPayment()方法),最后将带钩子@After的测试方法作为后置条件执行。
示例
@Before
public void method1(){
System.out.println("The precondition executed successfully");
}
@After
public void method2(){
System.out.println("The postcondition executed successfully ");
}
@Given ("^User is on payment page$")
public void navigateToPayment(){
System.out.println ("Payment screen navigation is successful");
}