On 4/17/06, Mikhail Loenko <[EMAIL PROTECTED]> wrote: <SNIP> > Why it is that complicated? > > Why one have jump over utility methods in different classes or even folders to > understand what a 5-line test does? > > testSomething() throw OtherException { > try { > ec.do_something_exceptional(); > fail("NullPointerException was not thrown!"); > } catch (NullPointerException e) { > //expected > } > } > > Let's keep simple things simple
Actually, it is not complicated. Because in the 'client' code you will have only small and intention-revealing checkes like: testExceptionalCase(new NullPointerCase() { public void exceptionalAction() throws Exception { } }); As I told that is well fits into OO conept and garantee you from not loosing any checks. Besides, it avoid duplication since you write only absolutely necessary code, not repeating try { ... fail(blah-blah-blah) } each time... If you need to check a message you have just to mention it is the constructor... It doesn't pretend to be the best choice. As I mantioned it was just how I do that. If you don't find this approach convenient and duplication-free don't use it :-). Wishes, -- Anton Avtamonov, Intel Middleware Products Division --------------------------------------------------------------------- Terms of use : http://incubator.apache.org/harmony/mailing.html To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]