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

后端 未结 25 2071
走了就别回头了
走了就别回头了 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:16

    Remove version declaration works for me:

    Example:

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>2.8.9</version>
            <scope>test</scope>
        </dependency>
    

    remove 2.8.9

    After:

        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
    

    It may due to version issue between jar packages of this dependency.

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

    Missing reference to:

    • byte-buddy-1.6.5.jar
    • byte-buddy-agent-1.6.5.jar
    • objenesis-2.5.jar

    Since Mockito 2.0.2 beta, Mockito-core has dependencies.

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

    Just update to the latest release of org.mockito:mockito-core. Once I did, the errors disappeared!

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

    This problem with Mockito2 occurs if you enable the option to mock final classes.

    This means when in your test/resources/mockito-extensions directory you have the file called org.mockito.plugins.MockMaker with the following content mock-maker-inline.

    In that case byte-buddy, which is a transitive dependency for mockito-core, has the problem to attach own agent to the java process. But the problem occurs only when you use JRE.

    The solution would be either:

    • Use JDK instead of JRE

    or

    • add -javaagent:byte-buddy-agent-*.jar as a VM option
    0 讨论(0)
  • 2020-12-29 01:20

    Mockito 2 requires dependencies. Adding the two ByteBuddy dependencies below. solved the issue for me:

    • byte-buddy-x.x.xx.jar
    • byte-buddy-agent-x.x.xx.jar

    In my case I include jar files in the project, which can be found at: https://bintray.com/raphw/maven/ByteBuddy/

    If you need it for a Maven project, simply add:

    <dependency>
      <groupId>net.bytebuddy</groupId>
      <artifactId>byte-buddy</artifactId>
      <version>1.9.14</version>
      <type>pom</type>
    </dependency>
    
    0 讨论(0)
  • 2020-12-29 01:21

    For me the problem was that IntelliJ ran the test as integration test. So I needed to create JUnit test manually

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