有了这个枚举:
public enum Testnum {
A("a"), B("b");
String x;
private Testnum(String x) {
this.x = x;
}
}
此测试中的assertFalse失败:
import static org.junit.Assert.assertFalse;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@SuppressStaticInitializationFor("Testnum")
public class EnumTest {
@Test
public void mainSuccess() {
PowerMockito.mockStatic(Testnum.class);
assertFalse(Testnum.A == Testnum.B);
}
}
我知道为什么/如何解决这个问题?