Code Monkeyism

Programming is hard by Stephan Schmidt

Moved cintoo Messages from jMock to EasyMock

Several reasons convinced me to move cintoo Messages from jMock to EasyMock 2. The main reason is that jMock has no static importable methods for mock creation and verification. The way to do this in jMock is to extend a jMock TestCase class. Unfortunately this class depends on JUnit, so when moving to TestNG I still had to keep the JUnit jar around. Also TestNG promotes a no-inheritance test structure where jMock just doesn’t fit in. The second reason is that I was bitten by method name refactorings several times. As some methods were equal in different classes, IDEA wrongfully replaced the methods strings in jMock which broke lots of tests. Another minor reason is that jMock doesn’t seem to move very fast.

The transition has been made easier by EasyMock as that framework adopted a lot of ideas from jMock in version 2.x (I think :-). I still hope to use the jMock spinoff assertion DSL though with assertThat( eq(5), …).

In the last years since the first jMock release I’ve been convincing clients to use jMock for their unit testing. I still think jMock is great for JUnit, but it just doesn’t work with TestNG in the current version.

About the author: Stephan Schmidt is currently a team manager at ImmobilienScout24 in Berlin. Stephan has been working as a head of development and CTO. He has used a lot of different technologies in the last 20 years including Java, Rails and Python. Stephans main field of interest is maintainablity and productivity in software development. Want to know more? All views are only his own.

If you did like this article but you don't want to subscribe to new articles with your reader, you can follow me on Twitter or subscribe to new posts with your email:

Leave a Reply