I was experimenting jMock as my mocking framework for my project. I came into a situation where I need to mock both a class and an interface. I used the ClassImposteriser.INSTANCE
to initiate the impostor of the context.
Supposing a class Validator
and an interface Person
to mock. When I was going to mock the Interface Person
, I ran to a problem NoClassFoundDefError
. When I mocked the class Validator
, there was no problem.
I need both that class and interface but I can't solve the problem. Please HELP.
Code Example:
Mockery
private Mockery context = new JUnit4Mockery() {{ setImposteriser(ClassImposteriser.Class) }};
Class :
private Validator validator;
Interface :
private Person person;
Inside Test Method
validator = context.Mock(Validator.class);
----> Working
person = context.Mock(Person.class);
---->NoClassFoundDefError