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

Jesse Yates commented on HBASE-5456:
------------------------------------

I don't see it as that big of a deal that power mock breaks the ide 
refactorings vs the gain of having truly cleaner code bases. Instead of having 
these protected test-only methods, you don't need to have any methods at all 
(also, why have them protected when you can just make them package private and 
just have tests in the same package? And should you really be testing across 
packages if this doesn't work? Probably not).

Yeah, it can be a pain that the ide doesn't automagically take care of this 
stuff for you, but you should know which tests you are changing and if those 
elements are in fact correctly changed. On the small scale (per patch), you 
probably aren't going to be changing more than a handful of broken methods (if 
that).

bq. My take is that we'll use PowerMock when it makes sense

Which is how it should be used - we just need to be diligent to make sure that 
we really need to dig into the internals of a class rather than test around the 
public interfaces. Granted, we do have a lot of stuff that isn't amiable to DI, 
but powermock can help a lot with that too (catching constructor calls,etc) 
without having to rewrite massive amounts of code.

bq.  PowerMock isn't exactly a walk-in-the-park

It's got some "interesting features" but the docs are actually pretty 
comprehensive. It just takes a little getting used to :)
                
> Introduce PowerMock into our unit tests to reduce unnecessary method exposure
> -----------------------------------------------------------------------------
>
>                 Key: HBASE-5456
>                 URL: https://issues.apache.org/jira/browse/HBASE-5456
>             Project: HBase
>          Issue Type: Task
>            Reporter: Zhihong Yu
>
> We should introduce PowerMock into our unit tests so that we don't have to 
> expose methods intended to be used by unit tests.
> Here was Benoit's reply to a user of asynchbase about testability:
> OpenTSDB has unit tests that are mocking out HBaseClient just fine
> [1].  You can mock out pretty much anything on the JVM: final,
> private, JDK stuff, etc.  All you need is the right tools.  I've been
> very happy with PowerMock.  It supports Mockito and EasyMock.
> I've never been keen on mutilating public interfaces for the sake of
> testing.  With tools like PowerMock, we can keep the public APIs tidy
> while mocking and overriding anything, even in the most private guts
> of the classes.
>  [1] 
> https://github.com/stumbleupon/opentsdb/blob/master/src/uid/TestUniqueId.java#L66

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to