I have several switch statements which test an enum
. All enum
values must be handled in the switch
statements by a case
s
In case there are several enums on different tiers of the project that must correspond to each other, this can be ensured by a test case:
private static > String[] names(T[] values) {
return Arrays.stream(values).map(Enum::name).toArray(String[]::new);
}
@Test
public void testEnumCompleteness() throws Exception {
Assert.assertArrayEquals(names(Enum1.values()), names(Enum2.values()));
}