Search the web
Sign In
New User? Sign Up
junit · JUnit, the Java unit testing framework written by Kent Beck and Erich Gamma.
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Hear how Yahoo! Groups has changed the lives of others. Take me there.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
JUnit Anti-patterns   Message List  
Reply | Forward Message #16150 of 22044 |
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.

Cheers,
Joe










Sat Feb 18, 2006 12:24 am

copabella
Offline Offline
Send Email Send Email

Forward
Message #16150 of 22044 |
Expand Messages Author Sort by Date

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...
Joe Schmetzer
copabella
Offline Send Email
Feb 21, 2006
8:26 pm

... Good start...one to add off the top of my head... Using the wrong assertXxxx Example assertTrue("errmm they dont match", obj1.equals(obj2)); ...
Andrew McDonagh
andy_ipaccess
Offline Send Email
Feb 21, 2006
8:39 pm

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...
Cédric Beust 
cbeust
Offline Send Email
Feb 21, 2006
8:54 pm

... 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...
David Saff
dsaff
Offline Send Email
Feb 22, 2006
6:55 pm

... 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...
J. B. Rainsberger
nails762
Offline Send Email
Feb 23, 2006
6:11 am

... 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 ...
Cédric Beust 
cbeust
Offline Send Email
Feb 23, 2006
6:25 am

... 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...
J. B. Rainsberger
nails762
Offline Send Email
Mar 1, 2006
1:07 am

... [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...
Joe Schmetzer
copabella
Offline Send Email
Feb 23, 2006
10:42 pm

... I agree completely with Cedric. Failures and errors are intended to be very different beasts, and this difference is highlighted in various test result...
jason r tibbetts
tibbettj_at_...
Offline Send Email
Feb 24, 2006
4:13 pm

... 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...
Joe Schmetzer
copabella
Offline Send Email
Mar 1, 2006
11:20 pm

... 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...
jason r tibbetts
tibbettj_at_...
Offline Send Email
Mar 2, 2006
3:21 pm

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...
Kent Beck
kentlbeck
Offline Send Email
Feb 27, 2006
7:20 pm

... 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...
J. B. Rainsberger
nails762
Offline Send Email
Mar 1, 2006
1:09 am

... 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...
jason r tibbetts
tibbettj_at_...
Offline Send Email
Mar 1, 2006
3:05 pm

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 ...
Kent Beck
kentlbeck
Offline Send Email
Mar 2, 2006
4:32 am

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@...
Send Email
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...
David Saff
dsaff
Offline Send Email
Feb 22, 2006
6:55 pm

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@...
Send Email
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...
J. B. Rainsberger
nails762
Offline Send Email
Feb 23, 2006
6:06 am

... Use the JUnit-Addons's junitx.framework.ArrayAssert.assertEquals() on each list's toArray() output. http://junit-addons.sourceforge.net...
jason r tibbetts
tibbettj_at_...
Offline Send Email
Feb 23, 2006
3:50 pm

... 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...
Joe Schmetzer
copabella
Offline Send Email
Feb 23, 2006
10:41 pm

... Last PMD plug :-) - it catches this case too: http://pmd.sourceforge.net/rules/junit.html#UseAssertEqualsInsteadOfAsse rtTrue Yay static analysis! Yours, ...
Tom Copeland
tomcopeland_...
Online Now Send Email
Feb 21, 2006
9:45 pm

... cool! I haven't been keeping up to date with PMD... so thanks for the heads up!...
Andrew McDonagh
andy_ipaccess
Offline Send Email
Feb 21, 2006
10:11 pm

... 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...
Tom Copeland
tomcopeland_...
Online Now Send Email
Feb 23, 2006
10:40 pm

... no need for talking pornographic Tom... ;-)...
Andrew McDonagh
andy_ipaccess
Offline Send Email
Feb 23, 2006
10:42 pm

... Did I? Must have been the JavaCC part... racy stuff, those parser generators.... Yours, Tom...
Tom Copeland
tomcopeland_...
Online Now Send Email
Mar 1, 2006
11:19 pm

... Thanks Andrew. That's a good example. I'll add them in. Cheers, Joe...
Joe Schmetzer
copabella
Offline Send Email
Feb 23, 2006
10:41 pm

... Hi Joe - Might be worth adding a link to the PMD JUnit checks: http://pmd.sourceforge.net/rules/junit.html UnnecessaryBooleanAssertion, for example, checks...
Tom Copeland
tomcopeland_...
Online Now Send Email
Feb 21, 2006
9:45 pm

... 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...
Joe Schmetzer
copabella
Offline Send Email
Feb 23, 2006
10:41 pm
First  | < Prev  |  Next > Last 
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help