EricGao888 commented on PR #11332:
URL: 
https://github.com/apache/dolphinscheduler/pull/11332#issuecomment-1221893292

   > Powermock is getting more and more annoying such as 
https://github.com/apache/dolphinscheduler/runs/7929368593?check_suite_focus=true
   > 
   > 
[powermock/powermock#1112](https://github.com/powermock/powermock/issues/1112)
   > 
   > I'd rather just review and remove all those tests involving Powermock...
   
   @kezhenxu94 To follow up on this comment, I did some experiments on 
replacing `Powermock` with `Mockito` and it worked well, see #11588. I think it 
is possible to remove the dependency of `Powermock`. 
   
   For some more difficult cases such as:
   1. Legacy code using some external APIs which are really hard to mock
   2. Legacy code instantiating stuff with `new` keyword 
   
   We could:
   1. Encapsulate the external APIs 
   2. Inject dependencies as below: 
   
![image](https://user-images.githubusercontent.com/34905992/185851674-37204ca1-9eb6-4b56-9631-abb41aac4b2f.png)
    
    
https://stackoverflow.com/questions/15052984/what-is-the-difference-between-mocking-and-spying-when-using-mockito#:~:text=about%20partial%20mocks.-,Mockito.,passed%20to%20spy()%20method.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to