我有一个测试,我配置了一些通用夹具,但使用PowerMockRule后,我在我的@BeforeClass方法中配置的静态变量重置为null。这会导致以下测试失败,但是如果您移除PowerMockRule它会通过。PowerMockito和@BeforeClass通用夹具设置
public class Test
{
@Rule
public PowerMockRule rule = new PowerMockRule();
private static String MyString;
@BeforeClass
public static void setupClass() throws Exception
{
MyString = "FOO";
}
@org.junit.Test
public void test() throws Exception
{
assertEquals("FOO", MyString);
}
}