lundi 7 décembre 2020

How to test a method that returns an enum

What would a simple mocking test using mockito look like of getAnimalOf?

enum Animal{
    Cow,
    Pig;
}
public static Animal getAnimalOf(String s) {
    return // Processing happens ...
}

I want to convert this dummy test into a mocking test, but how? (The following is just a vague idea of a test)

String s = "..,.,.notRealProductionAnimal,..,,.."
assertThat(getAnimalOf(s), is( Animal.notRealProductionAnimal ))

Aucun commentaire:

Enregistrer un commentaire