How JUnit's assertArrayEquals() should be implemented

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],

Assert.assertEquals("Array length mismatch", expected.length,

3 comments :: How JUnit's assertArrayEquals() should be implemented

  1. Take a look at hamcrest. It has a multiple built-in matchers.

  2. I have read your blog its very attractive and impressive. I like it your blog.

    Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

    Online Java Training Online Java Training | Java J2EE Online Training | JavaEE Training Institute in Chennai m

  3. Thanks for posting this blog. This was very interesting blog, I felt comfortable while reading this post, thank you..........................To knowOracle Training

Post a Comment