我有一個測試,我配置了一些通用夾具,但使用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);
}
}