Jul 13th, 2010, 02:09 AM
Automatic Mocking with Spring framework
I am suppose to write unit testing code for my business layer by mocking DAO layer.
I have tried to use the JMock API for this and i could inject the Mock DAO objects into the Business objects manually.
But i thought that it is a dirty way to inject mock objects. The tough think i could face using JMock is in setting up the mock data and injecting the mock objects manually.
As i am already using Spring framework for my application, i thought of making use of Spring for unit testing and automatically injecting DAO mock objects into BO objects while unit-testing.
Is there a way to define mock objects, setting expectations for mock objects, maintaining test
data using spring specifically using Spring configuration files. (in a configurable way)
Hope iam clear on my requirement. Thanks in advance for your time and attention.
Tags for this Thread