Using mocks in tests

Maybe you know the situation. Having a Foo java class which needs testing. But damn, it needs another class which gets data from the database,
does another complicated thing ™, … . So you create a DummyFooSupport class. Which is only used for tests to create default and defined values.

After trying easymock I think it is a better way to use mocks. Mocks are used to imitate classes. You take an interface and tell it how it should behave and
what it should return. This spares you to create dozens of DummyFoo, DummyBar, … classes.

Looks complicated. The important thing to see is that Collaborator is an interface from which an object can be created without implementing a Dummy class.
In this case the mock object does nothing. But you can specify which returns methods are giving and lot more. Just look at the documentation (from where this example is also from).