Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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");
    }
}
like image 409
Sudheer Avatar asked Dec 20 '22 03:12

Sudheer


1 Answers

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.

like image 95
Sudheer Avatar answered Apr 26 '23 06:04

Sudheer