Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to glue multiple steps directories to a cucumber test in Intellij?

I have a Cucumber scenario whose steps are defined in multiple Step files, as opposed to only having only one. If I decide to run the test using Intellij I go to run/debug configurations menu and the form provides a field named glue which enables me to specify the steps package.

So far I was able to run the scenarios that have all steps defined in the same Steps file, but I was unable to figure out how to do it for the scenarios that require multiple steps files located in different packages. I've tried a csv approach but without success. Does anyone know what I am missing? Thank you for your help.

like image 992
João Matos Avatar asked Oct 24 '25 11:10

João Matos


1 Answers

There are few ways to configure the glue paths with Cucumber.

As a cucumber.properties file in the root package (usually src/test/resources/cucumber.properties):

cucumber.glue=com.example.steps1,com.example.steps2

Via the command line

--glue com.example.steps1 --glue com.example.steps2

Or with the @CucumberOptions annotation.

@RunWith(Cucumber.class)
@CucumberOptions(glue ={"com.example.steps1", "com.example.steps2"})
public class RunCucumberTest {

}

When using IDEA you have to separate the glue packages with a new line or space (not a comma!).

com.example.steps1
com.example.steps2

And if you are on a recent version of Cucumber (6+) you don't have to provide the glue at all. Cucumber will search the class path by default.

like image 63
M.P. Korstanje Avatar answered Oct 27 '25 01:10

M.P. Korstanje



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!