Our application has a service layer and a DAO layer, written as Spring beans.
While testing the Service Layer- I do not want to depend upon a real database so I am mocking that by creating a 'Mock' Impl for the DAO layer
So when I am testing the Service layer- I chain the Service layer beans to the Mock DAO beans And in Production- will chain the Service layer to the 'real' DAO beans
Is that a good idea ? Any alternate suggestion on how to mock the database layer ?
Clarification:This question is about testing the Service Layer and not the DAO layer. While testing the service layer- I assume that either the DAO layer has already been tested or doesn't need testing. The main thing is- how do we test service layer- without being dependent upon the DAO implementation- hence I am mocking the DAO layer