Tiago Veloso Tiago Veloso - 2 days ago 4
Java Question

JUnit 3 - Array contains a given element

I am trying to assert that a given array contains at least one instance of a given element. Is there an assert method that already does this? If so which one?

I am using Java6 and JUnit3.

Answer

Not a built-in assert, no. You'd need to use assertTrue() and check the array yourself using something like Arrays.binarySearch(), ArrayUtils.contains(), or your own method.

Comments