[Catalyst] writing a test suite for my app

Matt S Trout dbix-class at trout.me.uk
Fri May 19 17:50:29 CEST 2006

Perrin Harkins wrote:
> On Fri, 2006-05-19 at 16:52 +0200, Daniel McBrearty wrote:
>> I think I can see why this is the case - in T:W:M:Catalyst.pm ...:
>> # check if that was a redirect.  These codes based off of
>>     # 
>> http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
>>     if ( grep { $response->code() == $_ } 301, 302, 307 ) {
>>       # blah ... essentially do the redirect ...
>>     }
>> He doesn't check in the base object to see if  redirects are allowed. 
> What he's doing here is simulating hitting your web application without
> actually making any HTTP requests.  No offense to Leon, but I think this
> is a poor way to test.

I'm afraid you're dead wrong there. TWMC uses Catalyst::Test, which as clearly 
documented, simulates by *default* but if a CATALYST_SERVER environment 
variable is present goes and does a full live test using the copy of the 
application running at the URL in that environment variable.

 > If there are issues caused by your server's
> configuration or other modules loaded, you will never see them.  My
> suggestion would be to stop using this module and just use
> Test::WWW::Mechanize against a running server instead.  It may be
> slower, but it will be a more accurate test.

Except that that's a complete pain for local tests, since it's difficult to 
find a URL you can rely on for the application without knowing your local 
network configuration; this can be seen clearly by the fact that 
Test::WWW::Mechanize has to be force installed on every development server we 
have since its won tests rely on http://localhost/ without checking to see if 
$ENV{http_proxy} is set. I've filed an rt.cpan ticket explaining this mistake, 
but have seen no response to it as yet.

      Matt S Trout       Offering custom development, consultancy and support
   Technical Director    contracts for Catalyst, DBIx::Class and BAST. Contact
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

+ Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +

More information about the Catalyst mailing list