Welcome to the Monastery | |
PerlMonks |
Re^3: Tool to record subroutine calls & return valuesby stevieb (Canon) |
on Apr 09, 2017 at 22:57 UTC ( [id://1187539]=note: print w/replies, xml ) | Need Help?? |
You do not need to know what's going in or coming out of each sub to begin writing a test suite. Knowing the code flow/stack trace is way enough to begin, and you don't even need to know that really. Start from the very top of your legacy code base. Write tests for the very first function encountered, with expected in and check the out. If there are subs called within the sub, mock them out to return what you *believe* it currently should so that the flow goes ok. Trickery may be required in the tests if your software does side-effects within its subs, but I digress. This is one of the reasons side-effects can be a pain in the ass. Do this for each sub in the entire process flow. You do not need to change absolutely anything until every single current sub is tested. At the point you've tested them all, knowing what to mock and what to allow to run through, you'll have a full test suite that will allow you to start a re-write. Write the whole shebang anew, or set up a dev environment to start making modifications. Your test suite will catch any problems now, and this is where you start expanding on the test suite you've already started. Most of my Perl early years was spent writing software to deal with issues exactly like this, and since then, I've never stopped. Writing code to help other developers develop is my favourite thing to do with Perl, and a good number of my own modules on the CPAN are geared around development aids and test/build work.
In Section
Seekers of Perl Wisdom
|
|