Giter VIP home page Giter VIP logo

Comments (2)

GoogleCodeExporter avatar GoogleCodeExporter commented on September 15, 2024
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 [email protected] on 14 Mar 2015 at 9:32

from powermock.

GoogleCodeExporter avatar GoogleCodeExporter commented on September 15, 2024
It seems to be fixed with PowerMock 1.6.2!

Original comment by [email protected] on 24 Mar 2015 at 6:53

from powermock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.