Am 22.01.2012 21:56, schrieb Simone Tripodi:
Hallo BenediktNo 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
What do you mean with mixing behavior? myMethod(null, someParam) and myMethod(someParam, null), both throwing NPE is essentially the same, isn't it? But as I said earlier, I see the benefits of small test methods, that really do only one thing. I will keep that in mind for future contributions. Also, I will refactor the existing unit tests, when I have the time.
good night! Benedikt
http://people.apache.org/~simonetripodi/ http://simonetripodi.livejournal.com/ http://twitter.com/simonetripodi http://www.99soft.org/ --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
--------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
