in reply to Tests for CGI apps

The advice from merlyn about testing the different parts of the app separately is good. For the actual controller part, if you're using CGI::Application, I found the approach described here worked very well for me. Otherwise, Mechanize is a good choice. You will have to include some setup to put fake data into your database. This sounds like a lot of work, but it's really worth it to have piece of mind. WIth a good set of tests, you can instantly tell if your code is still working after you make a change somewhere.

Replies are listed 'Best First'.
Re: Re: Tests for CGI apps
by jest (Pilgrim) on Nov 18, 2003 at 22:01 UTC

    Thanks for the various ideas.

    I regret that I have not, thus far, cleanly separated my M from my C, though my V is nicely off in TT. But I can probably adopt some form of mixing Test::* tests with a WWW::Mechanize implementation. Hope this isn't too time-consuming to implement....

      Hope this isn't too time-consuming to implement...

      If you're planning to maintain and develop your code base it'll be worth it no matter how long it takes.

      You'll eventually find yourself modifying your application so it's easier to write tests for.. this is a good thing. It'll probably mean you're making your code more modular which will in turn make it easier to develop.

      oh, and you'll know it was all worth it when you make a quick and simple change which "won't affect anything else" and your test suite finds and identifies a bug in 10 seconds..

      I've spent a lotta time writing tests and improving my app to make it testable over the last 6 months, but I still don't think I've come close to the amount of time I've saved compared to manual testing and searching for bugs...

      cheers,

      J