I've just updated the JUnit Anti-patterns page I maintain at http://www.exubero.com/junit/antipatterns.html. I'd be interested in
any feedback, if people want to suggest additions or improvements.
I've just updated the JUnit Anti-patterns page I maintain at http://www.exubero.com/junit/antipatterns.html. I'd be interested in any feedback, if people want...
Hi Joe, ... I don't really understand this: This is a design decision that permeates JUnit, and when you decide to report multiple failures per test, you begin...
... The sophomores taking MIT's software engineering lab were given a test suite last week that had dozens of asserts per test method. One student managed to...
... I would think this refers to wanting later assertions to execute after a previous assertion fails, which JUnit doesn't do on purpose. ... I see many people...
... Sorry, I meant to put the fail in the try{} block of course, not catch{}. The point was that letting the method throw and declare the exception in the ...
... It's /no/ way to test for exceptions. How would I write an assertion? :) (I imagine that was your point.) ... ...unless you want to check the exception...
... [snip multi-assert arguments already answered by David] ... throw an ... and do a ... Hi Cédric, I would argue that explicitly calling fail is less useful...
... I agree completely with Cedric. Failures and errors are intended to be very different beasts, and this difference is highlighted in various test result...
... Hmmmm... I understand the distinction, but personally I find that sticking to this rule in the case of unexpected exceptions makes it *harder* to figure...
... You're right in stating that for unexpected exceptions, it's foolish and overly verbose to use a try/catch where the catch clause calls fail. It's...
With all the recent (in the last decade) activity in developer-written tests, conventions for effective tests are still forming. I think these kinds of...
... How often have you wished your test verified data stored in the expected exception? Ever? This is the one bit that surprises me, because I often want to...
... This is an important point. For example, what if you have a method that will throw an IllegalArgumentException if any of its three arguments is null? It's...
Joe, In JUnit, we have a few tests that check the error messages. Mostly, though, all I care about is that potential users will see the correct kind of ...
I'd suggest using Assert#assertEquals(String,Object,Object) to compare two different java.util.Collection implementations (e.g. ArrayList, Arrays.ArrayList) -...
Stephen Smith
steve@...
Feb 21, 2006 9:20 pm
... Can you give more details? What's the API you'd like to have, but don't? Thanks, David Saff...
The fact that Assert#assertEquals(Object,Object) makes it easy to accidentally compare two different implementations of java.util.Collection is more of a...
Stephen Smith
steve@...
Feb 23, 2006 10:09 pm
... I don't understand the problem. If two implementations of List have equal elements at the same indices, equals() returns true for them. At least, it does...
... that. :( Hi Stephen, I'd be inclined to argue that that example is *not* really an anti-pattern, but rather a limitation of the API. But, I guess you could...
... Last PMD plug :-) - it catches this case too: http://pmd.sourceforge.net/rules/junit.html#UseAssertEqualsInsteadOfAsse rtTrue Yay static analysis! Yours, ...
... No problemo! Hopefully we'll be able to put together some appropriate checks for JUnit 4 annotation-based tests... should be doable since the latest...
... Hi Joe - Might be worth adding a link to the PMD JUnit checks: http://pmd.sourceforge.net/rules/junit.html UnnecessaryBooleanAssertion, for example, checks...
... Thanks for that Tom. I think that those links and explaination would be really beneficial for the anti-patterns. I'll add them in RSN. Cheers, Joe P.S. I...