How to test ENUMs using JUNIT
assertEquals("FRAME", CosProfileType.FRAME.name());
It will work only when field and value both are same but won't wotk for below:
FRAME ("frame_value")
Better to check with
assertEquals("FRAME", CosProfileType.FRAME.getFieldName());
You are comparing and String
to an Enum
that will never be equal.
Try:
@Test
public void testAdd() {
TrafficProfileExtension ext = new TrafficProfileExtension();
assertEquals("FRAME", ext.CosProfileType.FRAME.toString());
}
Since CosProfileType
is declared public static
it is effectively a top level class (enum) so you could do
assertEquals("FRAME", CosProfileType.FRAME.name());