FEST-Mocks is a Java library which mission is to minimize potential shortcomings of Mock Objects.
More information about the potential shortcomings of mocks can be found at:
FEST-Mocks requires Java SE 5.0 or later and can be used with either JUnit or TestNG.
One of the shortcomings of using mocks is introduction of clutter and duplication in our code. Take a look at this example using EasyMock:
The problems with the code listing above are the following:
- There is no clear separation of mock expectations and code to test
- Calls to
- It is easy to forget to call
verifyin every test method, which will result in failing tests
A solution to this problem is FEST's EasyMockTemplate:
- We have eliminated code duplication (calls to
- We have a clear separation of mock expectations and code to test
- We no longer have to call