in reply to Adding Tests to Mature Web App

Hopefully, most of your core functionality is in modules and abstracted from the presentation. If so, you can do a lot of testing without worring about pretending you're a browser.

As far as adding tests to an existing codebase, In addition to the book mentioned above, Perl Medic has a decent section.

When I've been in a similar situation, I've tried to add the simplest test(s) possible without changing the existing code at all, and then slowly re-factored the code to make it more test friendly (if needed) while keeping the original tests in place to verify nothing's been broken. Usually when I'm up against code without tests, I didn't write it, so you may be a step ahead in that regard.

Replies are listed 'Best First'.
Re^2: Adding Tests to Mature Web App
by skx (Parson) on Aug 09, 2006 at 16:06 UTC

    I'd second this comment.

    I took over a large and mostly monolithic application. At the time there were no test cases and so I went through and did two things at once:

    • Wrote test cases against an imaginary modular-API.
    • Broke the code into many small modules.

    Over time 99% of the code has been turned into objects and modules and now I have a good place to add more tests.

    Testing a large monolithic application is quite hard.

    Although if you can install an instance upon a test environment (perhaps along with a test database with contents, etc) you may be able to use the WWW::Mechanize family of modules to fire requests against it and parse the results back out.

    Steve
    --