Unit testing built-in functionsby aijin (Monk)
|on Nov 08, 2006 at 22:45 UTC||Need Help??|
aijin has asked for the
wisdom of the Perl Monks concerning the following question:
We've started doing test-driven development at my office, and that means writing lots of unit tests.
My current task involves taking a bunch of pre-existing, scattered code and turning it into a module.
There are a lot of built-in calls in the code, and I'm not sure how to tackle them in the unit tests.
For example, for a call like this:
I would like to be able to have that call fail on a file that should be there, but isn't...as if someone had deleted the file while the program was running. Or perhaps it exists, but can't be deleted.
I am familiar with Test::MockModule and Test::MockObject and was hoping that there was a module that mocked built-in calls so that I could manipulate them in the same way. So far, my search-fu has failed me and I can not find such a module.
Likely, I am missing an obvious solution. Would someone care to enlighten me?