Make "context injection" possible via property injection as well #18
gasparnagy
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Would that then be limited to BoDi and other DI libraries that support property injection, or would something like Microsoft.Extensions.DependencyInjection also be supported? |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context Injection (that is in fact a simplified DI) has a lot of benefits to share data, state and services accross step definition classes.
My experience was howerer, that if someone is not used to that, using the "constructor injection" pattern we support is too difficult. In comparison, if you use Cucumber with Spring DI, the property injection is much simpler. (I train both, so I see the learning curves of both of them.)
So the idea would be to provide a capability of injecting the objects via properties as well. (Constructor injection would still remain.)
My initial idea is to try injecting dependencies to any public settable properties of the binding classes, so you don't even need to mark them as injectable via attributes. (Of course we could have attributes as well to override the default behavior or exclude a particular property.)
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions