When comparing JMockit vs EasyMock, the Slant community recommends JMockit for most people. In the question“What are the best mock frameworks for Java?” JMockit is ranked 2nd while EasyMock is ranked 3rd. The most important reason people chose JMockit is:
The official tutorial contains thorough explanations and discussions of all methods, annotations, fields etc.., with lots of easy to understand examples. The API documentation is very complete as well and it provides detailed explanation for all elements of the mocking API.
Ranked in these QuestionsQuestion Ranking
Pro Great resources
The official tutorial contains thorough explanations and discussions of all methods, annotations, fields etc.., with lots of easy to understand examples.
The API documentation is very complete as well and it provides detailed explanation for all elements of the mocking API.
Pro Can mock everything
JMockit has the ability to mock final classes and final, private and static methods whereas other mocking frameworks only work on a few of these.
Pro Instance capture ability
Being able to capture instances and mock implementations as the test executes without having any knowledge of the actual implementation classes allows JMockit to verify these special objects through regular assertions with custom validation methods for each matching object.
Pro Great resources for beginners
A great step-by-step guide for installation and first use is provided by the EasyMock team. In addition there is the full API available for browsing and understanding the framework more.
EasyMock allows for developers to be able to switch between nice, normal, and strict mocking controls.
Pro Full interaction control
EasyMock requires the user to put down all interactions in code, allowing full control over all interactions that will occur between EasyMock and the code. Other frameworks take care of these interactions which can lead to test scenarios out of the developers control.
Con Learning curve is a bit steep
Since JMockit has a much larger scope that other mocking frameworks and as a result, the learning curve will be a bit steep.
Con Small community
Although EasyMock has great resources including their User guide and Javadocs, there is a need for a dedicated community that it seems to not have. Other frameworks have more support and community around them resulting in more developers choosing other frameworks.