How JUnit's assertArrayEquals() should be implemented

3 comments
I find myself writing this assertion method at (almost) any project where #tests > K where K is typically 10. In other words: Every project.



public static void arrays(Object[] actual, Object... expected) {
for(int i = 0; i < Math.min(actual.length, expected.length); ++i)
Assert.assertEquals("Array mismatch at index " + i + ":", expected[i],
actual[i]);

Assert.assertEquals("Array length mismatch", expected.length,
actual.length);
}