I recently added Mockito to a maven project on eclipse, by adding the external jar "mockito-core-2.0.53-beta.jar", and upon attempting to create my first mock object (Line two in the function)
And upon running it, the console prints out the first line, then throws this error:
It seems like previously there was a similar issue, but it was supposedly fixed internally. https://github.com/raphw/byte-buddy/issues/99
What is going wrong here?
You simply forgot to add the dependencies to your project which are according to the pom file:
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.3.16</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>2.1</version>
<scope>runtime</scope>
</dependency>
In other words you need to add byte-buddy 1.3.16
and objenesis 2.1
to your project too.
More details here
Instead adding
mockito-core
better option will to add
mockito-all
Refer to this link https://mvnrepository.com/artifact/org.mockito/mockito-all/2.0.2-beta
There is a post that explain the problem pretty well, you can find it here:
https://solidsoft.wordpress.com/2012/09/11/beyond-the-mockito-refcard-part-3-mockito-core-vs-mockito-all-in-mavengradle-based-projects/
If you are not using gradle or maven and you are just using mockit-core you should add these dependencies:
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>1.7.9</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>2.4</version>
<scope>runtime</scope>
</dependency>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With