Using WWW::Mechanize without a Web server

Ovid on 2007-01-16T17:22:14

This is the second time I've written this and the first time was years ago, so I don't recall what I was doing. I am writing our Web tests so we can pass a --noserver switch and run the code directly. That means overriding WWW::Mechanize::_make_request and pretending to be a Web server, knowing how to call your code, setting up the proper %ENV variables, following redirects, etc. So far I have this debugging information along with the tests:

> > > GETing login.pl
> > > POSTing login.pl
< < < Redirect requested to /login.pl?login=2
> > > GETing /login.pl?login=2
< < < Redirect requested to /
> > > GETing /

That tells me I've successfully logged in, handling cookie information and all that. Then the code blows up, but it's getting closer! When it's done, we'll be able to debug our Web tests much more easily.


Test::WWW::Mechanize::Catalyst

ChrisDolan on 2007-01-16T18:49:14

Not sure if it will help in your environment, but Catalyst has a nice solution for this.

Re:Test::WWW::Mechanize::Catalyst

Ovid on 2007-01-16T19:08:15

Ah, looks vaguely similar to what I've written. It would be nice if a generic solution could be provided for this. Since I'm writing this for work, I can't release the code.

Test::WWW::Mechanize::Object

rjbs on 2007-01-17T02:17:27

We use this to accomplish something similar: http://search.cpan.org/user/hdp/Test-WWW-Mechanize-Object-0.020/lib/Test/WWW/Mechani ze/Object.pm

Re:Test::WWW::Mechanize::Object

Ovid on 2007-01-17T07:13:14

Argh! I checked on the CPAN and glanced that that module, but I didn't really look at it as closely as I should have. I was thinking "run mech without a Web server" and that code is "run mech with requests on an object". D'oh! Ah well :)

WWW::Mechanize::CGI

Hansen on 2007-01-17T16:16:59

WWW::Mechanize::CGI and Test::WWW::Mechanize::CGI might fit your needs better. If you want to roll your own, HTTP::Request::AsCGI (used by WWW::Mechanize::CGI and Catalyst::Test) makes CGI simple =)