-
Notifications
You must be signed in to change notification settings - Fork 250
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
feat(dependency injection): Add dependency injection for plugins #1313
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* Created `Injector` class, a readonly class that can instantiate `Injectable`s * Updated the `PluginLoader`, so it can load plugins with the new way of working as well as provide a Bridge plugin for all "old fashion" plugin * Started implenenting the `BroadcastReporter` and other Reporters in the new way. Couldn't help to make some quality of life improvements: * `StrykerOptions` now have the expected required/not required properties. * Created "test-helpers" package so we can share test helpers between packages.
The TestInjector is a new way of creating your System Under Test (sut) objects. You can configure what to inject and then call `TestInjector.inject(SutClass)`
Also added some unit tests for the Injector class.
* Made the context of the Injector generic. * Made injector readonly and type safe * Moved all injector related stuff to its own package: 'typed-inject' * Updated TestInjector class to now use the new typed-inject * Updated Stryker to now use the new typed-inject * Updated Stryker-api to now use types from typed-inject
…d move implementation of functions to stryker-util
…t it in its own PR
Move all stryker plugin stuff back to the api. Talked about it with Simon. We'll allow small pieces of implentation code in the api, as long as it doesn't have any side effects
3 tasks
simondel
reviewed
Jan 22, 2019
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reviewed it 🎉
Could you take a look at my comments?
I've implemented all review comments I think. Thanks 👍 |
Awesome :) Thanks. Feel free to merge 👍 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds dependency injection to Stryker, in preparation of removing the side effects from the way we now load plugins. Instead of registering yourself to the correct factory (for example, by calling
ReporterFactory.instance().register
), it relies on plugins exporting a property calledstrykerPlugins
.Just to be clear: this PR does fix not the issue reported in #667. It only adds the dependency injection mechanism to Stryker. We still need to do PR's for each package (can go relatively fast)
The content of this PR:
typed-inject
to the packages folder; A type safe dependency injection frameworkstryker-api/di
which contains dependency injection related interfaces to help plugins know what to (type-safely) injecttyped-inject
as a dependency to the core Stryker package and use it. Reporter plugins are loaded via this new mechanism.PluginLoader
in order to enable dependency injection in all plugins. It is still backward compatible with the old way of loading plugins.@stryker-mutator/test-helpers
. This package contains atestInjector
to help inject common stuff into injectables for testability purposes.BroadcastReporter
and all build-in reporters to now use the new dependency injection mechanism (as a demo implementation and tryout mostely).HtmlReporter
to work with the new way of loading pluginsThere is still some work to be done. However, this PR can already be reviewed for the most part. Not changing a lot anymore.
HtmlReporter
implementation so it can be reviewed in separate PR. -> feat(html-reporter): Remove side effects from html reporter #1314typed-inject
in its own readmetyped-inject
to make sure un-typesafe dependency injection results in compiler errorsRemove specific helper methods per plugin:Unfortunately not possible. Moved the methods to "plugins" package insteadreporterPlugin
,configEditorPlugin
, ... in favor of oneplugins
helper method. I think this is possible