-
-
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
Ability to configure PicoContainer #290
Comments
I've added a basic Cucumber project at https://github.com/rapaul/cukejvm-web-driver-switching/ which has an ugly hack in the constructor of MyWebDriver to choose the right driver based on an environment variable. Provided as a more concrete example of why the MyHooks type approach would be nicer. I've yet to look into how this could be achieved. |
I am looking for a way to make the constructors of my step definition classes depend on interfaces instead of concrete classes. Is it possible to achieve this with the current implementation of cucumber-jvm and picocontainer? Otherwise, the fix above seems to address this problem. |
I started looking into Guice for choosing an implementation while only depending on an interface. It all worked swimmingly, see https://github.com/rapaul/cucumber-jvm-guice-examples The Guice support in Cucumber allows for the loading of custom Guice Modules which enables this behaviour https://github.com/rapaul/cucumber-jvm-guice-examples/blob/master/src/test/java/test/MyModule.java So all of this is certainly possible using Guice, the only downside I see is that you need to annotate all your StepDefinition classes and any dependencies that also needs collaborators injected into its constructor. With PicoContainer this isn't required. I'm going to look at providing a similar function to custom Guice Modules for PicoContainer, adapting PicoFactory to support a custom 'Module' from which you can get access to the MutablePicoContainer and call pico.addComponent(componentKey, componentImplementationOrInstance). |
Thank you! I agree with you in that it would be desirable not having to pollute the implementation with dependency annotations. I wish you the best luck going forward with PicoContainer and hope to hear from you should you wish to share any progress. |
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. |
This feature request rises from http://groups.google.com/group/cukes/browse_thread/thread/a1e034468df4b5f2
In order to test across a range of environments
I want to configure the instance of a dependency in PicoContainer
Example snipped from the mailing list:
Currently it isn't possible to have an instance of
MutablePicoContainer
injected into theMyHooks
.The text was updated successfully, but these errors were encountered: