Skip to main content

Cucumber Options Glue

What is Glue in Cucumber?

Glue Option helps Cucumber to locate the step definition file. We specify the package to load glue code (step definitions or hooks) in the glue option. When no glue is provided, Cucumber will use the package of the annotated class. For example, if the annotated class is com.example.Runner then glue is assumed to be located in com.example.

Cucumber Glue Example

		plugin = {"pretty", "html:target/cucumber"},
		features = {"src/test/resources/features" }, 
		glue = {"com.pb.cucumbertest.stepdefinitions"}, 

public class Runner {


In example given above my step definitions files are inside package com.pb.cucumbertest.stepdefinitions. In case your test runner and step definitions files are in same package you can comment or remove glue line cucumber options.

In case your step definitions are in 2 different packages you can separate packages using comma:

glue = {"com.pb.cucumbertest.stepdefinitions", "com.pb.cucumbertest.util"}

and here you can see part of packages are common, so we can write like this

glue = {"com.pb.cucumbertest"}

Method Signature

  • String[] glue()
  • default {};
  • Returns: list of package names

Note: Your step definition and features files can contain subfolder as well. You do not need to make any additional changes; in that case, specifying the parent folder name is enough. 

Video Tutorial: Features and Glue in Cucumber

Submitted by tgoswami on December 28, 2021

Tarun has 11+ years of experience in Quality Assurance in different domains like Banking, E-commerce, Health and Education.


At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.