-
Notifications
You must be signed in to change notification settings - Fork 5k
[Improvement][Test] Remove dependency of powermock #11405
Copy link
Copy link
Closed
Labels
help wantedExtra attention is neededExtra attention is neededimprovementmake more easy to user or prompt friendlymake more easy to user or prompt friendlypriority:hightest
Milestone
Description
Search before asking
- I had searched in the issues and found no similar feature requirement.
Description
- As stated in [Improvement][UT] Upgrade junit to 5.+ #10976 (comment),
Powermockdoes not and will not supportjUnit 5. We need to remove the dependency onPowermock. - One possible way is to use a high version (greater than 3.4.0) of
Mockitoto mockstaticmethod, see: https://wttech.blog/blog/2020/mocking-static-methods-made-possible-in-mockito-3.4.0/
- Furthermore, we could use
Spotlessto block the usage ofPowermock. [Improvement][Test] Block the usage ofPowermock#11637
Sub-Tasks
I have split the task into six sub-tasks by workload:
- Remove
Powermockindolphinscheduler-api[Improvement][Test] Remove Powermock in dolphinscheduler-api #12144 - Remove
Powermockindolphinscheduler-datasource-plugin[Improvement][Test] Remove powermock in datasource-plugin module #12179 - Remove
Powermockindolphinscheduler-master[Improvement][Test] RemovePowermockindolphinscheduler-master#12124 - Remove
Powermockindolphinscheduler-common,dolphinscheduler-alert,dolphinscheduler-log-server,dolphinscheduler-spi,dolphinscheduler-worker[Improvement][Test] Remove powermock in common, alert, worker, etc. modules #12208 - Remove
Powermockindolphinscheduler-service,dolphinscheduler-server[Improvement][Test] Remove Powermock in dolphinscheduler-service and dolphinscheduler-server #12155 - Remove
Powermockindolphinscheduler-task-plugin[Improvement][Test] Remove Powermock in dolphinscheduler-task-plugin #12150
Examples
Currently we have several typical scenarios where we heavily rely on Powermock
- Mock static class
- Suppress
Static Initialization Error - Access private method in UT
... (to be continued)
I will give some examples and corresponding solutions for these scenarios respectively as follows:
- Add
mockito-inlineand useMockito.mockStaticas an alternative. - Simply mocking some special static classes with
Mockito.mockStaticwill causeStatic Initialization Error. For these special cases, we need to refactor the origin class with some tricks to decouple the usage of static method. - Change
privatemethod toprotected
For examples, see: #11588
Are you willing to submit a PR?
- Yes I am willing to submit a PR!
Code of Conduct
- I agree to follow this project's Code of Conduct
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is neededimprovementmake more easy to user or prompt friendlymake more easy to user or prompt friendlypriority:hightest