views:

40

answers:

1

I am working on a legacy code where there are several methods with calls to Stored procedures from the service layer itself as opposed to hibernate. Is it possible to test those methods in any manner so that my code coverage can increase ? I am using java 1.5 and sql server 2005.

+1  A: 

This sounds like a classic requirement for mocking. You would mock out the database connection and communication (via, perhaps, dependency injection) by supplying a mocked version of the objects that return static and consistent test data. As such you don't have to rely on the database connection (making your tests faster and more reliable).

Such frameworks exist for Java - check out JMock or EasyMock, for example.

Brian Agnew