Basically you have four options when you need to mock objects:
-
Implement them yourself just as you would create any other class.
-
Use premade mock objects. Obviously you won't be able to find any premade mock objects for your custom interfaces. But if you need to mock standard interfaces such as the HttpServletRequest interface there are freely available libraries. The Spring Framework, which I have used a lot, includes mock object implementations for some common standard interfaces. Over at mockobjects.com you will also find useful mock object implementations.
-
Use a static mock object creator such as MockCreator. This will create a skeleton class which implements your interface.
-
Use a dynamic mock object creator such as jMock or EasyMock. These will, at test time, create objects which implement the required interfaces.


Loading...
No selection was clipped for this page.