I'm generating the unit tests for my project, and I have a singleton class that looks like this
public enum MyEnum{
INSTANCE;
public String doSomething(String name){
return "My name is "+name;
}
}
This is how I was trying to do my unit test
@Test
public void test(){
String name = "Nacho";
String expectedResult = "My name is Nacho";
String resultToSend = "My name is Nacho";
MyEnum singletonMock = createNiceMock(MyEnum.class); //line A
expect(singletonMock.doSomething(name)).andReturn(resultToSend);
replay(singletonMock);
String actualResponse = singleton.doSomething(mock);
assertEquals(actualResponse, expectedResponse);
}
I know this is a pointless test, but bare with me. My problem is that on line A, I get a runtime error saying "Cannot subclass final class class MyEnum", and I know that it's because enums are final.
Any ideas?
Aucun commentaire:
Enregistrer un commentaire