cucumber/cucumber-jvm — pull request #634 by coekie (2013-11-19 23:43:50+00:00)
Title: Add hookpoints in Cucumber and GuiceFactory

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,...