您如何在Cucumber中使用正则表达式?
示例
功能文件
Feature: Exam Syllabus Scenario Outline: Summer and Winter Exam Schedule Given Exam time table in summer season Given Mathematics and Physics Syllabus Given Exam time table in winter season
步骤定义文件具有@Given(“([^\”]*)season$“)中的@Given时间表,该表在正则表达式的帮助下将两个Given语句映射到Feature文件中。
示例
@Given ("^Exam time table in ([^\"]*) season$") public void timeTable(String season){ if (season.equals("winter")){ System.out.println("The winter syllabus"); }else{ System.out.println("The summer syllabus"); } } @Given ("^Mathematics and Physics Syllabus$") public void syllabusList(){ System.out.println("Mathematics and Physics syllabus is"); }