Tiago Veloso Tiago Veloso - 1 year ago 141
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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download