[ 
https://issues.apache.org/jira/browse/HADOOP-7537?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13088912#comment-13088912
 ] 

Scott Carey commented on HADOOP-7537:
-------------------------------------

I have had mostly bad experiences with PowerMock. As Todd says, it is usually 
indicative of something that needs to be refactored or fixed; or is simply 
mis-used.

Tests that use too much PowerMock are extremely brittle, often failing in test 
code B after after changes in seemingly unrelated code A in ways that require 
deep knowledge of B.  It does some funky stuff in classloader land that results 
in painful to debug issues.  For example, I have seen static code initialized 
twice, leading to a test that hangs forever.

We have started to use phrases like "friends don't let friends abuse 
PowerMock".  Fixing a broken PowerMock test takes much longer than fixing an 
ordinary test.

It is a useful tool to have around, but needs to be used judiciously.   Every 
time it is used "because I must mock XYZ" ask, "why does XYZ need to be mocked? 
does it need changes to design to be testable?"

> Add PowerMock for the development of better tests
> -------------------------------------------------
>
>                 Key: HADOOP-7537
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7537
>             Project: Hadoop Common
>          Issue Type: Improvement
>          Components: build
>    Affects Versions: 0.23.0
>            Reporter: Kihwal Lee
>            Assignee: Kihwal Lee
>            Priority: Minor
>             Fix For: 0.23.0
>
>         Attachments: powermock.patch
>
>
> We already have Mockito, but PowerMock extends its capabilties so that we can 
> mock constructors and static methods. I find that it is extremely difficult, 
> if not impossible, to properly test some of the low-level features without 
> this. 

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to