There appear to be Assert.assertArrayEquals()
methods in Junit4 for all primitives other than double, e.g.
Assert.assertArrayEquals(int[] expected, int[] actual)
and
Assert.assertArrayEquals(char[] expected, char[] actual)
but not
Assert.assertArrayEquals(double[] expected, double[] actual, double eps)
or
Assert.assertArrayEquals(double[] expected, double[] actual, double[] eps)
(the latter to account for variable ranges of doubles). Is there a fundamental reason why I should not write such a function?
JUnit 5 TutorialThe assertArrayEquals() method asserts that two object arrays are equal. If they are not, an AssertionError is thrown. If expected and actual are null, they are considered equal. Let's first create Book, BookService classes, and then we will write JUnit test cases to use the assertArrayEquals() method.
assertArrayEquals. Asserts that two object arrays are equal. If they are not, an AssertionError is thrown with the given message. If expecteds and actuals are null , they are considered equal.
The method seem to have been added in JUnit 4.6, but is for some reason missing in 4.5 and previous versions. I wouldn't expect any problems upgrading to a newer JUnit version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With