vendredi 6 mars 2015

How to imitate nonexistent enum values in tests?

I have following method:



public void methodToTest(Locale locale){
switch (locale) {
case EN:
...
break;
case FR:
...
break;
default:
throw new IllegalArgumentException(String.format("Unexpected locale: %s", String.valueOf(locale)));
}
}


and following enum:



public enum Locale {EN,FR}


Please help me to cover the default branch of switch. I have not ideas how to realize it.


Aucun commentaire:

Enregistrer un commentaire