Could not initialize plugin: interface org.mockito.plugins.MockMaker

后端 未结 25 2072
走了就别回头了
走了就别回头了 2020-12-29 01:01

I\'m getting following exception once tests is started:

    Testcase: treeCtorArgumentTest(com.xythos.client.drive.cachedtree.CachedTreeTest):  Caused an ERR         


        
相关标签:
25条回答
  • 2020-12-29 01:22

    I had Byte Buddy on classpath (is transitive dep of Mockito 2.8.9) and still got the exception. Reason for me was that I ran the Unit tests with JRE instead of JDK. Switching to JDK worked for me.

    0 讨论(0)
  • 2020-12-29 01:23

    I had the same exception when switch to Java 10 and Spring Boot 2. This dependency combination worked for me:

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>2.0.2-beta</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy</artifactId>
            <version>1.8.16</version>
        </dependency>
        <dependency>
            <groupId>net.bytebuddy</groupId>
            <artifactId>byte-buddy-agent</artifactId>
            <version>1.8.16</version>
            <scope>test</scope>
        </dependency>
    
    0 讨论(0)
  • 2020-12-29 01:25

    Adding a bnd aspect to this

    Adding on to Paskas' answer, you also have to include the dependencies in the cnf maven repository, if you're using one (like my cnf/central.mvn).

    org.mockito:mockito-core:2.21.0
    net.bytebuddy:byte-buddy:1.8.15
    net.bytebuddy:byte-buddy-agent:1.8.15
    org.objenesis:objenesis:2.6
    

    and for convenient referencing, you can include a bnd variable in your cnf/build.bnd

    mockito: org.mockito:mockito-core; version=2.21.0,\
             net.bytebuddy:byte-buddy; version=1.8.15,\
             net.bytebuddy:byte-buddy-agent; version=1.8.15,\
             org.objenesis:objenesis; version=2.6
    

    and in your project's bnd file

    -testpath:\
        ${mockito}
    
    0 讨论(0)
  • 2020-12-29 01:27

    If you are using powermock ensure that your dependencies point to:

    org.powermock:powermock-api-mockito2
    

    instead of

    org.powermock:powermock-api-mockito
    
    0 讨论(0)
  • 2020-12-29 01:28

    I encountered this issue and solved it by bumping my version of org.mockito.mockito-core to the latest release. I had been using an older release for quite some time.

    0 讨论(0)
  • 2020-12-29 01:28

    My dependency for mockito was under androidTestImplementation and not under testImplementation.

    I got the same error when I tried to use mockito with my unit tests. All I had to do was add the dependency.

    0 讨论(0)
提交回复
热议问题