I have following code to test:
Public MyClass() {
public static final boolean myFunc(int param1, String param2, long param3) {
SomeInterface var1 = SomeEnumImplementingSomeInterface.INSTANCE;
SomeOtherInterface var2 = var1.getInstanceOfSomeOtherInterface();
String str = var2.getValue();
if (str.equals("ABCD"))
return true;
else
return false;
}
}
Is there any way by which I can assign a mocked object to var1 here?
One way around to this I could think of is declare var1 as class variable (it has to be static in this case since the method accessing it is static), and then assign mocked object to it by whiteboxing. But I don't want to change the design just for the sake of testing it.
Please avoid suggesting me a change in the class design.