What is the best isolation environment for Java? JMock, Easymock, Mockito or others?

I understand that this was asked earlier, but the last time was in mid-2008.

If you started a new project right now, which one would you use and why? What are their strengths / weaknesses in terms of readability, usability, maintainability and overall reliability?

+7
java unit-testing mocking stub isolation-frameworks
source share
4 answers

I used Easymock before, but now I use Mockito. I found Mockito easier than Easymock. For a detailed comparison of Easymock and Mockito, you can refer to here

+7
source share

To explain our motivation, jMock is a stubborn library. It is intended to guide the development of OO, which focuses on protocols between collaborating entities. If you don't think of your systems this way, then this is probably not the best option.

+3
source share

I have been using EasyMock for some time. Continues to add new features that allow you to reach more of those hard-to-reach spots.

Mockito will save some lines of code for the most common test cases.

Could you tell us more about your needs or priorities? Pretty wide as indicated.

+1
source share

My (biased) answer will be JMockit . For quick comparisons with other bullying tools, see the comparative matrix .

The test code written with it should be more readable and better structured (there are examples of tests for comparison on the sides). The JMockit mocking API usually requires less “use” than other mocking APIs to write the same test. The biggest advantage, IMO, is that it does not cause any compromise of the project for the tested code. On the other hand, since JMockit relies on more advanced methods and has more features, it also has great potential for users to encounter unexpected difficulties.

0
source share

All Articles