hbase-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Todd Lipcon <t...@cloudera.com>
Subject Re: Mocking classes for unit tests Was: asynchbase-1.2.0-rc1 is available for download
Date Wed, 22 Feb 2012 20:28:25 GMT
On Wed, Feb 22, 2012 at 12:24 PM, tsuna <tsunanet@gmail.com> wrote:
> On Wed, Feb 22, 2012 at 9:23 AM, Ted Yu <yuzhihong@gmail.com> wrote:
>> Benoit's comment is directly related to our practice, especially when we
>> add new methods which are only called by unit tests.
> I didn't dare to say it, but now that you do… :P
> HBase exposes a TON of implementation details in public APIs.  Makes
> things harder to refactor because you don't know if anyone out there
> is relying on this method or extending that class.

The annotations stuff that Jimmy's working on will help a bit in terms
of clarifying which APIs are meant for public consumption and which
just happen to be public classes because Java's scoping sucks.

> Mocking out things that are hidden is certainly a bit harder than
> calling into a public API javadoced as "for test only", but if it
> keeps the APIs clean, then I think it's worthwhile.

One thing we've started to do in Hadoop is to actually name methods
"getFooForTests" or "setFooForTests" instead of just annotating them.
This makes clear that you should never call it from non-test code, and
relies on far less magic than PowerMock.


> --
> Benoit "tsuna" Sigoure
> Software Engineer @ www.StumbleUpon.com

Todd Lipcon
Software Engineer, Cloudera

View raw message