JUnit 3 - Array contains a given element
assertThat(Arrays.asList(yourArray), hasItem(yourElement));
This will give you fine-grained information in the event of a test failure. It will print out your element and the collection it's looking in.
You can cast the array to a list:
assertTrue(Arrays.asList(yourArray).contains(yourElement));
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.