gorghoa / ScenarioStateBehatExtension

Provide a way to share scenario state through steps
MIT License
33 stars 7 forks source link

Decouple steps argument injection and the store #30

Open gorghoa opened 7 years ago

gorghoa commented 7 years ago

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:

gorghoa commented 7 years ago

Possible leads: