locked
Refactoring code in constructor or stub/shim it out? RRS feed

  • Question

  • I have a method I'm testing. The constructor for this method calls to its base class constructor and then in its base class constructor it sets a few members and then executes a method to fetch data from a db then sets some of the database values to more members (all done in the constructor).

    Should I, in order to test my original method, remove the call to the database in the constructor and refactor it so it just sets some members, then I can easily run the constructor in my test and stub out any interfaces that are being passed in (in this case 1) or should I try to shim out the method in the contructor that makes the database call??


    chuckdawit

    Friday, May 31, 2013 4:56 PM

Answers