Support adding class instances in the PicoContainer with the PicoFactory
See original GitHub issueSummary
Improvement request: support adding class instances when extending the PicoFactory
to setup the global context.
Expected Behavior
As the PicoContainer
supports adding component that are class instances, it could be interesting to also offer this functionality using the PicoFactory
.
Current Behavior
It is only possible to add a component in the PicoContainer
based on a given Class
with the public boolean addClass(Class<?> clazz)
method.
Possible Solution
I wrote a custom PicoFactory
based on yours and the changes were quite simple:
I replaced the following line:
private final Set<Class<?>> classes = new HashSet<Class<?>>();
By:
private final Set<Object> classes = new HashSet<Object>();
And I added this method:
public void addClass(Object classInstance) {
classes.add(classInstance);
}
Context & Motivation
I wanted to inject mocks of some interfaces in my support classes to run my acceptance tests in a smaller scope but I couldn’t find an elegant way to do so using the PicoFactory
.
I can submit a PR with these changes if you want.
Issue Analytics
- State:
- Created 5 years ago
- Comments:16 (10 by maintainers)
Top GitHub Comments
Give us some more time stalebot - I’m still interested in this.
This issue has been automatically closed because of inactivity. You can support the Cucumber core team on opencollective.