Skip to content
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

Add hookpoints in Cucumber and GuiceFactory #634

Merged
merged 1 commit into from
Mar 23, 2014
Merged

Add hookpoints in Cucumber and GuiceFactory #634

merged 1 commit into from
Mar 23, 2014

Conversation

coekie
Copy link
Contributor

@coekie coekie commented Nov 19, 2013

Use case: Create a subclass of Cucumber that creates a subclass of
GuiceFactory that creates an injector that has the injector of the
application being tested as its parent.
That way:

  • The application stays in control of its own lifecycle (it can create its
    own injector), but steps are still scoped by scenario.
  • Step classes can get injected by dependencies from the application
  • The application's injector can be created once and shared between
    multiple scenarios to improve performance

I need these hook points for one particular case, but I made them as general as I could to fit other use cases:

  • The createRuntime method in the junit Cucumber runner can be used to customize anything about the Runtime, Backends, ObjectFactories,... The problem I faced here is that the automatic configuration by classpath scanning sometimes just doesn't work out. (Because it only allows one ObjectFactory on the classpath; so you cannot extend one, and all tests in the same module are forced to use the same one).
  • the overridable createInjector method allows having a parent injector (my use case) but also e.g. adding override modules, changing the injector's stage,...

Use case: Create a subclass of Cucumber that creates a subclass of
GuiceFactory that creates an injector that has the injector of the
application being tested as its parent.
That way:
* The application stays in control of its own lifecycle (it can create its
   own injector), but steps are still scoped by scenario.
* Step classes can get injected by dependencies from the application
* The application's injector can be created once and shared between
   multiple scenarios to improve performance
@aslakhellesoy
Copy link
Contributor

Please fix formatting. See CONTRIBUTING.md

@coekie
Copy link
Contributor Author

coekie commented Dec 3, 2013

Sorry, fixed formatting now.

aslakhellesoy added a commit that referenced this pull request Mar 23, 2014
@aslakhellesoy aslakhellesoy merged commit ec5728f into cucumber:master Mar 23, 2014
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling ec5728f on coekie:guice-parent-injector into * on cucumber:master*.

@lock
Copy link

lock bot commented Oct 25, 2018

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.

@lock lock bot locked as resolved and limited conversation to collaborators Oct 25, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants