Friday, July 1, 2011

Mocking classes with JMock

Normally, you'll get the following exception when you try to mock a class with jMock:

com.javaeenotes.YourClass is not an interface.

The solution is to use the ClassImposteriser when instantiating the Mockery class.

context = new Mockery() {

Now you can mock any class, just as interfaces. The complete instructions can be found on this web page.

No comments:

Post a Comment