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

I've inherited an extremely large app written with CGI.pm and running under mod_perl. It's well-written, as it goes (or would have been regarded as well-written 15 years ago), but everything is lumped together; there's no separation of concerns at all. It's the intention to rewrite this using modern standards (probably Catalyst or Mojolicious), but in the meantime, there are no tests for this app and I need to get at least some basic ones going. A Mechanize script is going to be the only way of accomplishing this, because of the lack of separation.

Is there a test framework that will run this internally, so that I don't have to have a separate Apache installation just for testing (it would be politically impossible to set something like this up)? Similarly, what's the easiest way to mock a database for testing purposes? (The production DB is SQL Server.)

I'm used to the various Catalyst things that do this seamlessly and behind the scenes. I don't really care about how to accomplish this, I just want some simple way of getting started so I can start writing test scripts.

Replies are listed 'Best First'.
Re: Testing large legacy CGI app
by Corion (Patriarch) on Jan 27, 2016 at 15:30 UTC

    You can simply run the CGI script from the command line, at least as long as it does not need mod_perl specifically.

Re: Testing large legacy CGI app
by LanX (Saint) on Jan 27, 2016 at 19:54 UTC
    why do you need mechanize to test a CGI? Calling the script directly with URL parameters will do too and is far better for testing.

    You could even "automatize" this by logging the passed parameters to create your test scripts.

    In the end it's only a state machine with in- and output.

    Have a look into the network console for of your browser (S-C-q in my FF) to compare details.

    Cheers Rolf
    (addicted to the Perl Programming Language and ☆☆☆☆ :)
    Je suis Charlie!