- Trending Categories
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 to map a step definition to a feature file in Cucumber?
We can map a step definition file to a feature file in Cucumber. This can be done using the below steps −
Step1− Create a feature file with .feature extension(say Login.feature) with the following −
Feature − Login Module
Scenario − Welcome Page Login verification
Given User is on Welcome Page
Then Welcome page should be displayed
Step2− Create a step definition java file(say stepDefination.java) having the mapping of the step definition file to the feature file.
Example
package stepDefinations; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; public class stepDefination { @Given("^User is on Welcome Page$") public void user_on_welcome_page() { System.out.println("User on welcome page"); } @Then("^Welcome page should be displayed$") public void verify_user_on_welcome_page() { System.out.println("User should be on welcome page"); } }
Project Structure
- Related Articles
- How to auto-generate a step definition to a feature file in Cucumber?
- How to create a step definition file for Cucumber in Java?
- How to create a Feature file for Cucumber in Java?
- How to create a test runner file for Cucumber in Java?
- Explain a Step Definition in SpecFlow.
- How to run tests using a test runner file for Cucumber?
- Explain a Feature file in SpecFlow.
- How to make a Website step by step?
- Drag and Drop a File feature in React JS
- How to break your addictions in a step by step manner?
- How to convert a List to a Map in Kotlin?
- How to Clone a Map in Java
- How to reverse a Map in Kotlin?
- What are the main file components in Cucumber?
- How to skip a particular test method from execution in Cucumber?

Advertisements