Cucumber Options Glue

Cucumber Options Glue

Table of Contents

  1. What is Glue in Cucumber?
  2. Cucumber Glue Example
  3. How Glue Locate Step Definitions
  4. Method Signature
  5. Video Tutorial

What is Glue in Cucumber?

The glue option helps Cucumber locate the step definition file. In the glue cucumber option, we specify the package to load the glue code. Where glue code is our step definitions or hooks.

Cucumber Glue Example

		plugin = {"pretty", "html:target/cucumber"},
		features = {"src/test/resources/features"},

public class TestRunner {


In the example above, my step definitions files are inside package com.teststep.demo.stepdefinitions.

How Glue Locate Step Definitions

When the value for the glue option is not 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.runner. In other words, If your test runner and step definitions files are in the same package, you can comment or remove glue line in cucumber options. 

In other case, If your step definitions are in 2 different packages, you can separate packages using a comma and double quotes.

glue = {"com.teststep.demo.stepdefinitions1", "com.teststep.demo.stepdefinitions2"}

Here, you can see part of the package is common, so we can write like this:

glue = {"com.teststep.demo"}

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

Also, we use the --glue option in the cucumber command line, which we will discuss later when discussing cucumber command line options. 

Method Signature

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

Video Tutorial: Cucumber Options Glue

Managed ad

Tarun Goswami
Tarun possesses over 12+ years of extensive expertise in software testing and automation utilizing diverse JavaScript and Java technologies. Concurrently, he has dedicated his free time to crafting insightful blogs within the field.