For now (as of v1.0.x), we have implemented our business needs (share some state within a scenario) with a convenient DX way: injecting scenario state through steps’ methods arguments plus annotations.
After some time using this solution, we found that it is indeed nice to use, adding some clarity and less set-up in step.
But, behat does not offer a convenient way to hook in the steps’ argument injection and we had to replace (using dependency injection) core classes of Behat. It worked, but we knew that it could lead to potential compatibility break with other extensions (and it actually did #28).
Proposed solution
Decouple the framework level step arguments injection from our initial needs (storing pieces of states and sharing them).
The proposed steps' arguments injector should be able to be hooked by behat extensions, letting extensions react to step calls by providing new arguments.
Using annotations, developer shall not be surprised by the origin of the argument: everything should be kept explicit
Expectations
By decoupling the extension business logic from the more framework level technical step argument injector, I expect:
ScenarioStateBehatExtension to be kept simple and focused on the state sharing business
Easier compatibilty with other extensions
Allow other extensions to hook in argument injection
Maybe, the StepArgumentInjector to be accepted upstream by the behat team🤞
Context
For now (as of v1.0.x), we have implemented our business needs (share some state within a scenario) with a convenient DX way: injecting scenario state through steps’ methods arguments plus annotations.
After some time using this solution, we found that it is indeed nice to use, adding some clarity and less set-up in step.
But, behat does not offer a convenient way to hook in the steps’ argument injection and we had to replace (using dependency injection) core classes of Behat. It worked, but we knew that it could lead to potential compatibility break with other extensions (and it actually did #28).
Proposed solution
Decouple the framework level step arguments injection from our initial needs (storing pieces of states and sharing them).
The proposed steps' arguments injector should be able to be hooked by behat extensions, letting extensions react to step calls by providing new arguments.
Using annotations, developer shall not be surprised by the origin of the argument: everything should be kept explicit
Expectations
By decoupling the extension business logic from the more framework level technical step argument injector, I expect: