- 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 do you use regular expressions in Cucumber?
We can use regular expressions in Cucumber for selecting a collection of similar statements in the feature file.
Example
feature file
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
The step Definition file has @Given("^Exam time table in ([^\"]*) season$") which maps two Given statements in a Feature file with the help of regular expression.
Example
@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"); }
Advertisements