[Spring] CucumberBackendException: No qualifying bean of type
See original GitHub issueWhen trying to run step defs with abstract class contains all the context configuration spring sees 2 differnt beans parent and stepdef
I’m using spring boot version: 2.6.4 , with Junit 5 and cucumber version 7.2.3
@SpringBootTest(classes = CoreApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = AbstractIntegrationTest.Config.class)
@CucumberContextConfiguration
public abstract class AbstractIntegrationTest implements En {}
@Suite
@IncludeEngines("cucumber")
@SelectClasspathResource("com/example/bdd")
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "com.example.bdd")
public class CucumberIntegrationTest {
}
public class MyStepdefs extends AbstractIntegrationTest{
public MyStepdefs() {
When("^client post to \"([^\"]*)\" with valid data$", (String arg0) -> {
});
Then("^the client receives status code of (\\d+)$", (Integer arg0) -> {
});
}
}
Exception Stack trace:
io.cucumber.core.backend.CucumberBackendException: No qualifying bean of type 'com.orange.ces.core.bdd.AbstractIntegrationTest' available: expected single matching bean but found 2: com.orange.ces.core.bdd.MyStepdefs,com.orange.ces.core.bdd.AbstractIntegrationTest
at io.cucumber.spring.TestContextAdaptor.notifyTestContextManagerAboutAfterTestMethod(TestContextAdaptor.java:124)
at io.cucumber.spring.TestContextAdaptor.stop(TestContextAdaptor.java:107)
at io.cucumber.spring.SpringFactory.stop(SpringFactory.java:161)
at io.cucumber.core.runner.Runner.disposeBackendWorlds(Runner.java:156)
at io.cucumber.core.runner.Runner.runPickle(Runner.java:78)
at io.cucumber.core.runtime.Runtime.lambda$executePickle$6(Runtime.java:128)
at io.cucumber.core.runtime.CucumberExecutionContext.lambda$runTestCase$3(CucumberExecutionContext.java:151)
at io.cucumber.core.runtime.RethrowingThrowableCollector.executeAndThrow(RethrowingThrowableCollector.java:23)
at io.cucumber.core.runtime.CucumberExecutionContext.runTestCase(CucumberExecutionContext.java:151)
at io.cucumber.core.runtime.Runtime.lambda$executePickle$7(Runtime.java:128)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at io.cucumber.core.runtime.Runtime$SameThreadExecutorService.execute(Runtime.java:249)
at java.base/java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:118)
at io.cucumber.core.runtime.Runtime.lambda$runFeatures$3(Runtime.java:110)
at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
at java.base/java.util.stream.SliceOps$1$1.accept(SliceOps.java:199)
at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1632)
at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:127)
at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:502)
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:488)
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
at io.cucumber.core.runtime.Runtime.runFeatures(Runtime.java:111)
at io.cucumber.core.runtime.Runtime.lambda$run$0(Runtime.java:82)
at io.cucumber.core.runtime.Runtime.execute(Runtime.java:94)
at io.cucumber.core.runtime.Runtime.run(Runtime.java:80)
at io.cucumber.core.cli.Main.run(Main.java:87)
at io.cucumber.core.cli.Main.main(Main.java:30)
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.orange.ces.core.bdd.AbstractIntegrationTest' available: expected single matching bean but found 2: com.orange.ces.core.bdd.MyStepdefs,com.orange.ces.core.bdd.AbstractIntegrationTest
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveNamedBean(DefaultListableBeanFactory.java:1271)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveBean(DefaultListableBeanFactory.java:494)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:349)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBean(DefaultListableBeanFactory.java:342)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1172)
at io.cucumber.spring.TestContextAdaptor.notifyTestContextManagerAboutAfterTestMethod(TestContextAdaptor.java:120)
... 30 more
Issue Analytics
- State:
- Created a year ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
CucumberBackendException: No qualifying bean of type
When trying to run step defs with abstract class contains all the context configuration spring sees 2 differnt beans parent and stepdef.
Read more >CucumberException No qualifying bean of type x is defined
I know that this is essentially a Spring exception but, as I mentioned, this configuration works fine when Cucumber 1.1.8 is set and...
Read more >No qualifying bean of type-Springboot - appsloveworld.com
[Solved]-CucumberBackendException: No qualifying bean of type-Springboot ... Place it into a separate package and mention it in @CucumberOptions (if you have it) ...
Read more >NoUniqueBeanDefinitionExcepti...
NoUniqueBeanDefinitionException: No qualifying bean of type available: expected single matching bean but found 2: The spring boot exception org.
Read more >Developers - [Spring] CucumberBackendException: No qualifying ...
[Spring] CucumberBackendException: No qualifying bean of type.
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
I wouldn’t be able to say that with certainty. You’d have to sprinkle some break points around in the
SpringFactory
and take a look.I’m going to say that using:
isn’t supported, there should be a single concrete instance of an
@CucumberContextConfiguration
annotated class for each test execution. And with #2174 I don’t see much reason to improve the usability or errors messages.