Can I easily automate testing of my cgi using Test::[something]?

S

SC

I'd like to automate testing on a current project. I read
Test::Tutorial and the related docs by Michael Schwern (Test::Simple and
Test::More) and everything seems prety clear to me.

The only problem is that all the examples are for testing modules.
(About which I don't really know anything). Is there any way I can test
the output from my cgi scripts as-is using some of these testing tools
or am I out of luck?

My cgis are fairly simple affairs taking some params, reading from some
files/DBMs then outputing html. I'm not doing anything really clever or
complicated but I find that the number of things I need to test for is
growing larger than I can easily handle manually.

I'd really appreciate it if anyone has link to a tutorial or howto on
the subject.


Scot
 
B

Bill

SC said:
I'd like to automate testing on a current project. I read
Test::Tutorial and the related docs by Michael Schwern (Test::Simple and
Test::More) and everything seems prety clear to me.

The only problem is that all the examples are for testing modules.
(About which I don't really know anything). Is there any way I can test
the output from my cgi scripts as-is using some of these testing tools
or am I out of luck?

My cgis are fairly simple affairs taking some params, reading from some
files/DBMs then outputing html. I'm not doing anything really clever or
complicated but I find that the number of things I need to test for is
growing larger than I can easily handle manually.

I'd really appreciate it if anyone has link to a tutorial or howto on
the subject.


Scot
Look at CGI::Test on CPAN. And use -T. Taint mode is your shield.

Most of the work is still trying to decide what to test and under which
circumstances, of course. You can easily spend more time revising the
tests than the CGI :).
 
D

David Efflandt

I'd like to automate testing on a current project. I read
Test::Tutorial and the related docs by Michael Schwern (Test::Simple and
Test::More) and everything seems prety clear to me.

The only problem is that all the examples are for testing modules.
(About which I don't really know anything). Is there any way I can test
the output from my cgi scripts as-is using some of these testing tools
or am I out of luck?

The best way to test CGI, short of the production server, is with various
web browsers on your own similar web server. What got me into Linux in
1995 was frustration trying to test perl scripts in Windows and then
massaging them to work in apache on my Solaris ISP (different paths, or
Unix things that could not be tested in Windows). Even though the path to
perl (which was perl4 then) or other paths might be different, that was
easy enough to fix with a symbolic links in Linux, so I could simply
upload the working scripts unmodified to Solaris.

Or you can install FreeBSD on a PC if your web host is BSD or FreeBSD.

If your production server is Windows, my experience with IIS is limited
ftp or FrontPage access and minimal ASP to get by with a donated club site
(don't even know if it is configured for Perl and/or CGI).

There is no substitute for live testing, even if on a private server.
 
S

SC

Bill said:
Look at CGI::Test on CPAN. And use -T. Taint mode is your shield.

Most of the work is still trying to decide what to test and under which
circumstances, of course. You can easily spend more time revising the
tests than the CGI :).

Ah great, thank you. I should have looked there but got so hung up on
the Test:: suite that I forgot theres more tan one place to find it :)

....and yes, taint mode all the way :)
Actually, -wT, use strict, and $|++; are the first three things I add to
any new script (after tht #! of course)

Scot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top