-
-
Notifications
You must be signed in to change notification settings - Fork 2k
CucumberException: No qualifying bean of type 'Steps' available: expected single matching bean but found 1: Steps #1823
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
From what you've provided I honestly wouldn't be able to say what the problem is here. If you can provide it as an MCVE that would be much appreciated. Some guesses that you may want to investigate yourself:
Cucumber Spring can not share the application context between different test executions. This would cause concurrent modifications to the application context (all beans within the
After each scenario the |
I'll close this for now. Please feel free to reopen if you can provide more information. |
When executing Cucumber in parallel in combination with `cucumber-spring` users would often encounter a cryptic error message: "No qualifying bean of type 'Steps' available: expected single matching bean but found 1" (#1823). This was initially fixed by ensuring that the Spring application context was not shared between threads (#1153, #1148). This however has the downside that the application context is not shared with JUnit tests either (#1583) and comes at significant performance penalty (#1846). The root cause however was a race condition in `DefaultListableBeanFactory.registerBeanDefinition(String beanName, BeanDefinition beanDefinition)`. There is a check to see if the definition already exists. If it does not exist, it replaces the bean definition in a ConcurrentHashMap (in a synchronized block as well) but then adds the bean name to a list without checking if it already exists. By synchronizing inside `SpringFactory.start` we prevent concurrent modification of the application context by `cucumber-spring` This in turn makes it possible to share the application context between threads and with JUnit tests. Fixes: #1846 Fixes: #1583 Closes: #1848 Closes: #1582
When using a custom application loader,
expected single matching bean but found 1
is emitted. This behavior is non-deterministic but it seems sticky (I'm guessing there's some caching going on).We have something like the following code:
Expected behavior
No exception thrown.
Context & Motivation
During development, the tests are run directly from the IDE. Once committed and pushed, an app is built and deployed housing the tests and will execute them.
Stacktrace
Your Environment
Additional context
I've only seen the issue exhibit in a Docker container.
The text was updated successfully, but these errors were encountered: