commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Tripodi <simonetrip...@apache.org>
Subject Re: [SANDBOX][BeanUtils2] How to get rid of try/catch-blocks for expected exceptions in unit tests
Date Sun, 22 Jan 2012 20:56:49 GMT
Hallo Benedikt

>
> No it isn't. As far as I know, your test will pass, when the first
> NullPointerException is thrown (this also applies to @Rule
> ExpectedException). If you have a method that takes two arguments that are
> not nullable and you write:
>
> @Test(expected = NullPointerException.class)
> public void testMyMethod(){
>    // this will throw NPE
>    myObject.myMethod(null, someParam)
>    // test passes, because NPE was thrown, execution ends here
>
>    // this will never be executed
>    myObject.myMethod(someParam, null)
> }

mixing different behaviors inside test methods is IMHO not good, keep
it simple and straightforward (but not stupid) as Christian suggested
;)

-Simo

http://people.apache.org/~simonetripodi/
http://simonetripodi.livejournal.com/
http://twitter.com/simonetripodi
http://www.99soft.org/

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
For additional commands, e-mail: dev-help@commons.apache.org


Mime
View raw message