Ive recently entered into the world of mocking using jMock - in particular mocking in regards to db. Ive read some posts on how its not possible to (easily) mock a local object contained in a class / method. As Ive never actually done any proper TDD / mocking, Ive always defined objects such as 'ResulSet' in my methods where appropriate. Therefore my question is, when Im going forward with future DB classes / methods, should I define ResultSet as a field, and then have an appropriate Setter Method as a means to access it for testing?
If I should, is this still reasonable considering I probably wouldnt use this setter method for anything else but testing?
Essentially, am I to define all objects with setter methods to aid mocking?
I saw this post: Mocking methods of local scope objects with Mockito and it seems to suggest what Ive said above is acceptable.
I know it seems like a basic question, but I dont want to form bad habits early on.