Open GoogleCodeExporter opened 9 years ago
Same problem with PowerMock 1.6.1, Mockito 1.10.17, Java 1.8.0_40, OS X 10.10.2
while trying to mock a class with the mock() method of PowerMock:
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import static org.mockito.Matchers.anyVararg;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.powermock.api.mockito.PowerMockito.mock;
import static org.powermock.api.mockito.PowerMockito.whenNew;
@RunWith(PowerMockRunner.class)
@PrepareForTest(App.class)
public class AppShould {
@Test
public void startWithArguments() throws Exception {
final App appMock = mock(App.class);
whenNew(App.class).withNoArguments().thenReturn(appMock);
App.main(new String[]{"server", "config.yaml"});
verify(appMock, times(1)).run(anyVararg());
}
}
The exception thrown is:
java.lang.IllegalAccessError: tried to access class
org.mockito.internal.creation.cglib.CGLIBHacker from class
org.mockito.internal.creation.MethodInterceptorFilter
at org.mockito.internal.creation.MethodInterceptorFilter.<init>(MethodInterceptorFilter.java:34)
at org.powermock.api.mockito.internal.mockcreation.PowerMockMethodInterceptorFilter.<init>(PowerMockMethodInterceptorFilter.java:18)
at org.powermock.api.mockito.internal.mockcreation.MockCreator.createMethodInvocationControl(MockCreator.java:108)
at org.powermock.api.mockito.internal.mockcreation.MockCreator.mock(MockCreator.java:57)
at org.powermock.api.mockito.PowerMockito.mock(PowerMockito.java:143)
at xxxxx.xxxxx.xxxxx.AppShould.startWithArguments(AppShould.java:20)
Original comment by marcus.f...@gmail.com
on 14 Mar 2015 at 9:32
Original issue reported on code.google.com by
behran...@gmail.com
on 15 Dec 2014 at 3:39