I\'m getting following exception once tests is started:
Testcase: treeCtorArgumentTest(com.xythos.client.drive.cachedtree.CachedTreeTest): Caused an ERR
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.
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>
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}
If you are using powermock ensure that your dependencies point to:
org.powermock:powermock-api-mockito2
instead of
org.powermock:powermock-api-mockito
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.
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.