Can not convert from Class<PowerMockRunner> to Class<? extends Runner>

5.2k views Asked by At

I am trying to write Unit test cases using power mockito.

When using annotations @RunWith(PowerMockRunner.class) I am getting the following compilation error:-

TypeMismatch: cannot convert from Class<PowerMockRunner> to Class<? extends Runner>

Here is the code snippet. Using junit 4.8.1 and power mock 1.6.2.

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.modules.junit4.PowerMockRunner;

@RunWith(PowerMockRunner.class)
public class XXXTest {
    @Test
    public void testOne() {
        if (true)
            System.out.println("Success");
    }
}
1

There are 1 answers

0
Sudheer On BEST ANSWER

I downloaded and added Powermock-Module-Junit4 jar and did not add the dependent jar Powermock-Module-Junit4-Common.jar. When added common jar Powermock-Module-Junit4-Common resolved the error.

Thanks, Vasu.