mercredi 2 mars 2016

General Fixture Setup with PowerMockito and @BeforeClass

I have a test where I configure some general fixtures however after using PowerMockRule the static variables which I configure in my @BeforeClass method reset to null. This causes the following test to fail however if you remove PowerMockRule it passes.

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);
    }
}

Aucun commentaire:

Enregistrer un commentaire