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:
unlink( $filename );
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Unit testing built-in functions
by perrin (Chancellor) on Nov 08, 2006 at 23:30 UTC | |
|
Re: Unit testing built-in functions
by ikegami (Patriarch) on Nov 09, 2006 at 00:33 UTC | |
by Sidhekin (Priest) on Nov 09, 2006 at 01:06 UTC | |
|
Re: Unit testing built-in functions
by davidrw (Prior) on Nov 08, 2006 at 23:12 UTC | |
by ikegami (Patriarch) on Nov 09, 2006 at 00:01 UTC | |
by aijin (Monk) on Nov 09, 2006 at 01:07 UTC | |
|
Re: Unit testing built-in functions
by sgifford (Prior) on Nov 09, 2006 at 04:02 UTC | |
by f00li5h (Chaplain) on Nov 09, 2006 at 08:44 UTC |