-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Fixes #1003: Allow reloading of plugins. #1006
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
Conversation
Codecov Report
@@ Coverage Diff @@
## release/2.x #1006 +/- ##
=================================================
+ Coverage 86.86% 86.86% +<.01%
- Complexity 2290 2291 +1
=================================================
Files 287 287
Lines 5801 5803 +2
Branches 684 684
=================================================
+ Hits 5039 5041 +2
Misses 571 571
Partials 191 191
Continue to review full report at Codecov.
|
Hm, I am not sure about this change. Preferably I wouldn't want to make this change, as the PluginRegistry is supposed to run only once. Can't you make a delegate- |
hmm @TimvdLippe, That is essentially my work around for now in Powermock. What happens in the case where we have multiple MockMakers in the classpath? We wouldn't have control to make sure that the delegate is used since it would be whichever one ClassLoader.getResource() returns? Is there something that depends on PluginRegistry not changing that I am missing? Or would you be more comfortable making our instance of mockmaker not final and only reloading that? |
We have had several issues with loading and illogical exceptions related to the Registry. Therefore I would like to avoid introducing multiple loading stages, where again stuff can go wrong. That's my 2 cents though, let's see what the others have to say about this. |
I also think that dynamic reloading plugins it is overhead and needless feature. I don't see any case when it is required. All tests in one test class always should be run with one MockMaker. If speak about case of using with PowerMock, then PowerMock reloads classes for each test class, so it's easy to implement It will be better to have a link to default/parent Mockito MockMaker. It will help implement delegate- |
Writing a DelegateMockMaker is simple but what where would one put it? Would we essentially make PowerMockMaker the delagate in PowerMock? What happens when a user has a 3rd MockMaker in their classpath? Now the user needs to write a delegate to another as well as writing a switch to turn off all other MockMakers. IMO that is needless overhead for someone trying to turn on/off something for different test classes. Right now PowerMock is not on ByteBuddy so b/c it is on the classpath, someone cannot take advantage of Mockito2 for tests that do not require PowerMock. They would be forced to write their own MockMaker and switch. If we cannot reload plugins, the switch is essentially just hardcoding things on and off. We are now forcing our users to understand implementation details of dependencies they need and to write delegates and switches. IMO that is much less idea that allowing one to choose to dynamically reload plugins when they choose. It would not change default behavior. If one reloads halfway through a test class, then we may get some weird messaging but we already get that when one expects Mockito2 features. |
I am closing this PR for now. We are planning to address the MockMaker issues in Mockito 3, since we are now shipping multiple versions and there is no proper way to choose one for a test. For example, if just one test requires the InlineMockMaker. Stay tuned and thanks for your patience! |
Fixes #1003: Allow reloading of plugins.
This is done by making the PluginRegistry non final and exposing a public static method in Plugins so that PluginSwitch's in the future can trigger a reload of plugins if it wants to disable/enable some of them.