I am trying to mock a final class
PowerMockito.mockStatic(TestFinalClass.class);
It is working from my eclipse when I run a single junit and ad
package test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
@PrepareForTest(FinalClass.class)
public class Tests {
@Test
public void test() {
PowerMockito.mockStatic(FinalClass.class);
}
}
This works for me. If you add 'PowerMockRunner' and 'PrepareForTest' annotations you don`t need to use extra vm arguments.