top of page

How to glue a Feature file to specific Step Definition file in cucumber

In order to automate any application in Cucumber tool, we need to create 3 files

  1. Feature file

  2. Step Definition file

  3. Runner file

When i was working on my first cucumber project, i have a faced an issue where my feature file is getting glued to incorrect Step Definition file. Here is the issue.

Initially I thought we need to have only one feature file with distinct gherkins. We can't re-use the gherkins in other feature files. But you can re-use gherkins . You have to create a runner file and glue the specific step to specific feature file. We have to create runner file under src/tst/java/StepDefinition. Here is the syntax.

package StepDefinition;

import org.junit.runner.RunWith;

import io.cucumber.junit.Cucumber;

import io.cucumber.junit.CucumberOptions;

@RunWith(Cucumber. Class)

@CucumberOptions(features="src/test/resources/features", glue={"StepDefinition"},

plugin = {"pretty","html:target/HtmlReports1/report.html",




public class Runner {


This way we can have feature file connected to appropriate step definition file.

1,447 views0 comments

Recent Posts

See All


Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page