cucumber-spring with @Configuration class fail with @Scope("cucumber-glue")
See original GitHub issueThey way the cucumber-glue scope get registered won’t work when you’re using some of these scoped components in your non-scoped components declared in your configuration.
For example:
public interface ComponentA{}
@Component
public class DomainComponent{
@Autowired
private ComponentA beingInjected;
}
@Configuration
public class MyTestConfiguration{
@Bean
@Scope("cucumber-glue")
public ComponentA componentA(){
return Mockito.mock(ComponentA.class);
}
}
@ContextConfiguration(classes=MyTestConfiguration.class)
public class MyGlueCode{
@Autowired
private DomainComponent domainComponent;
}
This is because the way the scope currently get registered, we need the ApplicationContext to add the scope into it.
Issue Analytics
- State:
- Created 8 years ago
- Comments:7
Top Results From Across the Web
Cucumber Spring and class configuration - Stack Overflow
Classes with no constructor parameters are annotated with @Component and @Scope("cucumber-glue") annotation so bean creation can be removed from ...
Read more >Spring – Cucumber Spring and class configuration - iTecNote
I'm using Spring 4.2.4, all cucumber dependencies in version 1.2.4. Config: @Configuration public class AppConfig { @Bean @Scope("cucumber-glue") ...
Read more >[cucumber-spring] Cucumber glue scope not registering.
This fails at runtime with the message: Caused by: java.lang.IllegalStateException: No Scope registered for scope 'cucumber-glue'. java.lang.
Read more >Cucumber Tests in Spring Boot with Dependency Injection
This guide shows you how to configure Dependency Injection for your Cucumber tests in Spring Boot.
Read more >IntelliJ IDEA - Run/Debug configuration: Cucumber Java
The Cucumber run/debug configuration enables you to run features or scenarios via the cucumber.cli.main class. For information on how to create and run ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes there is. You need to register the GlueScope directly in your configuration, like this:
However, you can’t do it directly since GlueCodeScope is package visible. The workaround is to create a new class with the @Configuration annotation in the same package as GlueCodeScope (which is cucumber.runtime.java.spring). Register the scope in it with the code above.
Then in your glue code, you must use that configuration in addition to your own.
The pull request i made does exactly this, except your don’t have to add it manually to your config, it’s done magically with ASM. I think it’s a bad thing, but haven’t found another way doing it; except maybe modifying something else directly in spring.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.