Gowtham Murugesan
Gowtham Murugesan

Reputation: 417

Mock objects in Junit test gives NoClassDefFoundError

When I mock objects in Junit test cases using of PowerMock and Mockito, I'm getting this exception:

java.lang.NoClassDefFoundError: org/mockito/exceptions/base/MockitoSerializationIssue

Upvotes: 9

Views: 13231

Answers (3)

Peter
Peter

Reputation: 5894

I got this when combining PowerMock with Mockito. Fixed by using compatible version as shown here: https://github.com/powermock/powermock/wiki/Mockito#supported-versions

Upvotes: 15

Jonas Pedersen
Jonas Pedersen

Reputation: 1054

You don't have to use the beta version. The latest 1.10.x should also work. I had the same problem when using 1.9.5, but changing to 1.10.19 fixed the problem.

Upvotes: 1

Omkar Shetkar
Omkar Shetkar

Reputation: 3636

Check version of your mockito lib. I see org.mockito.exceptions.base.MockitoSerializationIssue class in 2.0.2-beta. It is not present in 1.9.5 .

Upvotes: 1

Related Questions