![]() |
VOOZH | about |
Great testing includes isolation
Most parts of a software system do not work in isolation, but collaborate with other parts to get their job done.
In a lot of cases, we do not care about using real collaborators implementation in unit testing, as we trust these collaborators.
Mock Objects replace collaborators of the unit under test.
Isolation involves Mock Objects
To test a unit in isolation or mount a sufficient environment, we have to simulate the collaborators in the test.
A Mock Object is a test-oriented replacement for a collaborator. It is configured to simulate the object that it replaces in a simple way.
In contrast to a stub, a Mock Object also verifies whether it is used as expected.
EasyMock makes mocking easier
EasyMock has been the first dynamic Mock Object generator, relieving users of hand-writing Mock Objects, or generating code for them.
EasyMock provides Mock Objects by generating them on the fly using Java proxy mechanism.
If the thought of writing all the mock object classes you might need is intimidating, look at EasyMock, a convenient Java API for creating mock objects dynamically.
Dave Thomas an Andy Hunt, The Pragmatic Programmers, in IEEE Software May/June 2002
We were about to implement our own Mocking based on reflect.Proxy, but seems like you saved us lot of trouble.
Oren Gross, Mercury Interactive
EasyMock can save a lot of legwork and make unit tests a lot faster to write.
builder.com Java E-Newsletter for October 21, 2002
We just started to use EasyMock in an XP project and found that it eases writing our TestCases considerably. Moreover, it encourages us to make more frequent use of MockObjects leading to compositional and interface oriented designs. Not only is it well crafted and easy to use. It also enhances communication in the TestCase for it exposes the expected calls on the MockObject right where you need it.
Dierk Koenig, Canoo AG
I have been using EasyMock to unit test some web-based classes without requiring the presence of the app server and I am very impressed. It is extremely easy to use and makes writing the unit tests a breeze - great job!
Robert Leftwich