PowerMock prepare a class for test without using @PrepareForTest annotation

1.7k Views Asked by At

I have inherited a complex JUnit 4 test class which uses

@RunWith(MockitoJUnitRunner.class)

Because of a change in implementation I need to use some features from PowerMock to mock static and private methods. But when I try to switch at class level to

@RunWith(PowerMockRunner.class)
@PrepareForTest(MyClass.class)

I get lots of errors because Mockito annotations are not being properly handled.

The question is: can I keep the @RunWith(MockitoJUnitRunner.class) annotation and do programmatically the same as @PrepareForTest(MyClass.class) just when I need it for a class?

0

There are 0 best solutions below