is supplying a default constructor considered a best practice for testing? -
i'm working moles framework mocking. i'm running roadblocks objects don't have argument-less constructors. when create object in question, have provide id, kicks off call database set objects properties. means lot more interception via moles. if object had simple constructor testing go lot smoother.
i remember hearing somewhere providing default constructor important testing. when went google confirm recollection, couldn't find answer.
providing argument-less constructor: helpful or important testing? irrelevant?
i'm of opinion shouldn't doing sort of thing in object constructor anyway, since ties tests tightly database of use. dependency injection framework ninject massively here. don't have default constructor little setup , let ninject glue that's needed when create test objects.
i'm starting out ninject (and using moq) haven't had massive amount of experience removes need default constructors used testing. sorts out bit more , helps make tests totally independent of external.
i know it's language-independent question ninject might irrelevant it's general view on unit testing.
Comments
Post a Comment