Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I'm refactoring a CGI web-site, and I want to create a test suite for the site as a whole (as opposed to just unit tests). My thinking is that this would both give me a way of detecting if my changes are introducing bugs and perhaps find currently undiscovered problems. It would also allow testing from remote locations so that, if something goes down, I could localize it without leaving my bedroom.

Is there any standard way of going about doing this? There is a CGI::Test module, but it has several limitations (no cookies) and hasn't been updated in a couple of years. I could see myself writing extensive LWP stuff to do this, but I'd prefer not to if it isn't necessary. How do other monks approach this?

Replies are listed 'Best First'.
Re: Automating CGI Testing
by adrianh (Chancellor) on Sep 17, 2003 at 14:48 UTC
Re: Automating CGI Testing
by Corion (Patriarch) on Sep 17, 2003 at 14:57 UTC

    I did write some tests for both sides of the fence - for one the tests in WWW::Mechanize and WWW::Mechanize::Shell exercise and check the client side, and for the server side, there is some rudimentary idea in CGI::Wiki::Simple, test *52.t, which does a setup, run and teardown of a CGI script.

    I haven't found any good frameworks to do end-to-end CGI testing, but CGI::Application allows you to easily redirect the output of the CGI. You will still have to set up all the environment variables though.

    perl -MHTTP::Daemon -MHTTP::Response -MLWP::Simple -e ' ; # The $d = new HTTP::Daemon and fork and getprint $d->url and exit;#spider ($c = $d->accept())->get_request(); $c->send_response( new #in the HTTP::Response(200,$_,$_,qq(Just another Perl hacker\n))); ' # web
Re: Automating CGI Testing
by tcf22 (Priest) on Sep 17, 2003 at 14:49 UTC
Re: Automating CGI Testing
by drfrog (Deacon) on Sep 17, 2003 at 19:01 UTC
    all good tips

    that are good for program checks, but what about performance?

    i use siege / web siege, avail through freshmeat.net

    its good for stress testing the servers