I am new to JUnit testing. I want to mock a singleton class. The class looks like this.
public enum MockClass{
INSTANCE;
private MockClass(){
//private constructor
}
public void convertToString(int a){
return SomeClass.setString(a.toString());
}
}
I want to mock this class such that whenever there is a call to MockClass.INSTANCE.convertToString(a)
, nothing should be executed. There is a function in PowerMockito called doNothing()
. But what do I do for Singleton classes as shown above? In this case PowerMockito doesn't help.
Disclaimer: I cannot change the implementation of the class. It has to be enum. I am just unit testing the code developed by others.