Skip to content

Cucumber JUnit 5 Change of behaviour: Cannot have multiple spring boot cucumber contexts #2230

Closed
@davidmelia

Description

@davidmelia

Describe the bug
Cucumber Spring via JUnit 5 should auto default the glue path to the path of the running test otherwise this means you cannot have multiple spring contexts in the same project.

To Reproduce
https://github.com/davidmelia/cucumber-spring-junit5 contains an example. I have two JUnit 4 tests
CucumberJunit4Test1Test and CucumberJunit4Test2Test with their own spring glue which works fine where io.cucumber.java.JavaBackend picks the glue path [classpath:/com/melia/junit4/test1] and [classpath:/com/melia/junit4/test2] respectively. So far so good.

I also have two JUnit 5 tests CucumberJunit5Test1Test and CucumberJunit5Test2Test but they both default to the glue path [classpath:/] where I get the error

SEVERE: Unable to start Cucumber
io.cucumber.core.backend.CucumberBackendException: Glue class class com.melia.junit5.test2.CucumberJunit5Test2Steps and class com.melia.junit5.test1.CucumberJunit5Test1Steps are both annotated with @CucumberContextConfiguration.
Please ensure only one class configures the spring context
	at io.cucumber.spring.SpringFactory.checkOnlyOneClassHasCucumberContextConfiguration(SpringFactory.java:92)
	at io.cucumber.spring.SpringFactory.addClass(SpringFactory.java:65)
	at io.cucumber.java.JavaBackend.lambda$loadGlue$1(JavaBackend.java:41) 

Expected behavior
I would expect Cucumber JUnit 5 to default the glue path to the directory of the running test otherwise we cannot have multiple spring contexts in the same project which make migration impossible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions