This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I think this falls under the "Yes, that'd be cute" category. If the Java folks had thought of this way back when, they might indeed have implemented it, and it might have been useful. But introducing this now would likely break a lot of code, so don't look for it any time soon.
Yeah Jeanne, this could be a workaround, but doesn't work if you have classes that extend Assert, not my base test case. I have a helper class like this. Anyway, it's not a big problem to change it. [ April 21, 2005: Message edited by: Serge Adzinets ]
[EFH]: I think this falls under the "Yes, that'd be cute" category.
I'd put it in the "Yes, Java's designers should be kicking themselves for not including better methods for arrays from the beginning" category. But either way, I agree it's not likely to happen now; the window of opportunity was missed.
[Serge]: Yeah Jeanne, this could be a workaround, but doesn't work if you have classes that extend Assert, not my base test case.
Sure it works - with minor modifications to what Jeanne said. Make your new method static, just like all the other asserts in JUnit's Assert class. Then you can call it quite easily with something like "MyAssertionClass.assertArraysEqual(arr1, arr2);". If you don't like typing the "MyAssertionClass", well JDK 1.5 allows you static imports. But that's a minor issue. It's quite easy to call public static methods from anywhere you want; it just takes a tiny bit more typing.