I have No Scope registered for scope name 'cucumber-glue'
error while running Cucumber (6.1.1) BDD tests with Spring
My configuration file
@ContextConfiguration(locations = {"classpath:/application-context-bdd.xml"})
@CucumberContextConfiguration
public class Configuration {
}
My test file
@RunWith(Cucumber.class)
@CucumberOptions(plugin = {
"json:target/cucumber-json-report.json" },
glue = {"xx/java/bdd/configuration", "xx/java/bdd/stepdefs", "xx/java/bdd/steps"},
features = "classpath:features",
publish = false
)
public class TestBDD {
}
My application context file, where my cucumber-glue
bean is declared.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="todoRepository" class="xx.java.core.domain.mock.TodoRepositoryMock" scope="cucumber-glue"/>
<bean name="todoService" class="xx.java.core.domain.todolist.service.impl.TodoListServiceImpl">
<constructor-arg ref="todoRepository"/>
</bean>
<bean name="todoStep" class="xx.java.bdd.steps.TodoStep">
<constructor-arg ref="todoService"/>
</bean>
<bean class="xxx.java.bdd.stepdefs.TodoStepDefinition"> <!-- Not needed since @M.P. Korstanje reply -->
<constructor-arg ref="todoStep"/>
</bean>
</beans>
any idea ??
the solution is to declare all todoRepository
depending beans in cucumber-glue
scope
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean name="todoRepository" class="xx.java.core.domain.mock.TodoRepositoryMock" scope="cucumber-glue"/>
<bean name="todoService" class="xx.java.core.domain.todolist.service.impl.TodoListServiceImpl" scope="cucumber-glue">
<constructor-arg ref="todoRepository"/>
</bean>
<bean name="todoStep" class="xx.java.bdd.steps.TodoStep" scope="cucumber-glue">
<constructor-arg ref="todoService"/>
</bean>
</beans>