Yesterday at work I gave a presentation on Unit Testing. It went well. 160 slides! And, no one passed out and hit the floor.
One thing I mentioned was mocking frameworks and how JMockit is very useful. Perhaps JMockIt represents the state of the art in Java based Mocking tools.
There are plenty of good reasons for using mocks:
JMockit is ” a collection of tools and APIs for use in developer testing, that is, tests written by developers using a testing framework such as JUnit or TestNG.”
I’ve used it for some tests. Since it uses Java instrumentation it can mock almost anything, especially those legacy untestable great OO classes. Best of all it has a very good tutorial.
The only ‘negative’, so far, is that JMockit does not, afaik, have many developers working on the project. That could also be a plus, of course.
Another mock tool is PowerMock.
Seems to me there are too many mock frameworks and they do pretty much the same things. Time for consolidation so that an API and a body of practice can shake out?
- Mock object
- Beyond EasyMock and JMock, try JMockIt !
- The Difference Between Mocks and Stubs
- The JMockit Testing Toolkit
- The Concept of Mocking
- Unit Testing Using Mocks – Testing Techniques 5
- Making a mockery of CQ5 with JMockit
Off topic, some music … Stefano Cantini – Blowin in the wind