Mockito is a mocking framework that tastes really well. It lets you write beautiful tests with clean & simple API. Mockito doesn't give you hangover because the tests are very readable and they produce clean verification errors. Read more about features & motivations.
A small mock library that is extremely easy to learn with plenty of examples. Only has 5 classes for the api. This library's best feature is being able to test a 24 hour timer in milliseconds with a mockobject timer.
Java mocking is dominated by expect-run-verify libraries like EasyMock or jMock. Mockito offers simpler and more intuitive approach: you ask questions about interactions after execution. Using mockito, you can verify what you want. Using expect-run-verify libraries you are often forced to look after irrelevant interactions.
To someone who is new to unit testing, the idea of mock objects can be confusing to say the least. I have covered in previous tutorials how to use various mock object frameworks (EasyMock and jmockit). However in this tutorial, we will focus on the concept of mocking in general. What is a mock object? What is it used for? Why can't I mock object XYZ? Let's look into these questions and maybe clear a bit of the air on the use of mock objects.
JMockit Core consists of a single class with a small set of static methods, which allow arbitrary methods and constructors of any other class to be replaced with mock implementations at runtime.
This facility can be used for writing unit or integration tests, enabling the isolation of code under test from other parts of the codebase. This approach is an alternative to the conventional use of "mock objects" as provided by tools such as EasyMock and jMock.