-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
enable to customize cdi2 container initializer #2257
enable to customize cdi2 container initializer #2257
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2257 +/- ##
============================================
- Coverage 83.01% 82.38% -0.63%
- Complexity 2340 2342 +2
============================================
Files 307 308 +1
Lines 8324 8401 +77
Branches 768 771 +3
============================================
+ Hits 6910 6921 +11
- Misses 1110 1175 +65
- Partials 304 305 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So a few problems:
- System properties aren't quite universal. We have a number of different ways to pass properties, this would be yet another.
- I'm not happy with all the logic involved in
findPackage
andtoClasses
. I would rather see that we burden the user of Cucumber with these problems.
I would suggest we do something like the InjectorSource
in cucumber-guice
. And I would suggest doing something like we do with cucumber-spring
where the SpringBackend
tries to find a specific class and the SpringFactory
looks out for that class.
So as a quick sketch:
package com.example.stepdefinitions;
class MyCucumberSeContainerCustomizer implements CucumberSeContainerCustomizer {
public void customize(SeContainerInitializer sci) {
// do customizations here
}
}
|
I'm not suggesting SPI, I'm suggesting the customizer is part of the glue. This means there can be multiple customizers and depending on how Cucumber is configured different once are used. |
@mpkorstanje I see, I'm fine with that for a first version. Do you want to take over the PR to do it? |
I wasn't intending to. Would you be interested in adding a cdi2 backend that looks for implementations of |
@mpkorstanje I played a bit more with such pattern and came back to an old issue (fixed now): ObjectFactory = Container + Lookup. So overall this PR is useless if we get a CDILookup and CustomCDIContainer (which is way more easier to manage than a SPI whereever it is) or just a PassthroughContainer assuming the container is started with another extension before cucumber runs (which is also generally easy to do with junit like runners). |
Hi everyone , as i can see cdi2 uses a weld container. It would amazing if we could use WeldInitiator (Weld junit) as a CDI container for our cucumber scenarios because its fully customizable.
|
@iliadelo if you have a feature request you may want to start a new issue. |
Don't think it will work because there is nothing outside of Cucumber to start the container. I suppose you could use the before-all/after-all hooks to start a single static instance. But at that point you don't need CDI for DI any more. |
I think this got stuck. So I've written #2439. Let's see if any one wants to contribute a solution like that. |
Is your pull request related to a problem? Please describe.
Enable to use the CDI container initializer configuration using system properties.
Describe the solution you have implemented
Read cucumber.cdi2.* properties and wire them + a SPI to make it code first (easier in some cases, in particular for libraries).