0
有一个类X;模拟静态枚举内部最终类
public final class X {
private X() {}
...
public static enum E {
thingA("1"),
thingB("0")
public boolean isEnabled(){...}
}
...
}
在一些其他类
有一个方法M.
public class AnotherClass{
public void M(){
if (E.thingB.isEnabled()) {
doSomething();
}
}
...
}
我想测试M法,是可以使用的Mockito/powermockito到 模拟语句中如果。做这样的事情
when(E.thingB.isEnabled()).thenReturn(true)?
你自己尝试过吗? – 2015-02-05 17:02:14