"Writing mock objects on your own can be tedious, but there are a lot of mock frameworks out there to help you with this task. EasyMock is a library for creating mocks for interfaces on the fly using the dynamic proxy API. It's been around for a couple of years now, and besides being very stable and robust, another advantage is that it is well known. So here comes EasyMock2, ready to rock--er, mock--the world. My first idea was to introduce only the new features of version 2, but I recognized that there are still a lot of people out there not using EasyMock at all. So I'm going to show what you can do with EasyMock using the new version 2.2 API."
"Testing Strategies, Mocks, and Stubs In interaction-based unit testing, tests typically pass mock objects into methods so that the mock objects can verify the implementation of the code that is being tested. Mocks are fake objects that record the manner upon which they are operated and can verify whether they were operated on properly."
"When you're dealing with simple data or service objects, writing unit tests is straightforward. However, many objects rely on other objects or layers of infrastructure. When it comes to testing these objects, it is often expensive, impractical, or inefficient to instantiate these collaborators."
"Mock objects can help to solve this dilemma. Mock object tests replace domain dependencies with mock implementations used only for testing. This strategy does, however, present a technical challenge in certain situations, such as unit testing on remote systems. AspectJ, an aspect-oriented extension to the Java language, can take unit testing the rest of the way by allowing us to substitute test-only behavior in areas where traditional object-oriented techniques would fail."
"The use of mock objects is a widely employed unit testing strategy. It shields external and unnecessary factors from testing and helps developers focus on a specific function to be tested."