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 having the mapping of the step definition file to the feature file.


package stepDefinations;
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