mardi 9 février 2016

Match a string to an enum name

Is there any clean way of testing that a given String matches an enum name?

Right now I get

Expected: is <SUNDAY>
Actual: SUNDAY

I want to avoid having to add .name() to each check

assertThat("SUNDAY", is(SUNDAY.name()))

Something as

assertThat("SUNDAY", isEnum(SUNDAY))

I'm not asking how to write my own Matcher, I'm asking if there is already something built, which I can't seem to find.

Aucun commentaire:

Enregistrer un commentaire