Fake CGI environment for an external program

Suppose I have a CGI script, not necessarily written in Perl, and I want to unit test that.

Of course, I can just use the web server and LWP :: UserAgent, but I think it's a bit overkill.

So how can I run a CGI program from perl? For instance. in pseudo code:

my $reply = fake_cgi("/path/to/prog.cgi", foo=>"bar", count=>1);
like ($reply->content, qr/<title>/, "Title is always present");

I found this advice , but I would prefer a ready-made module.

+3
source share
2 answers

I think CGI::Testthis is what you are looking for. I did not use it myself, but he says

CGI:: Test CGI- , CGI , -, , -.

, CGI, CGI:: Test, Perl. , CGI , CGI- .

+4

CGI . STDIN ENV ( ). , STDOUT .

+1

All Articles