Jason Purdy wrote:
> I'm lining up my next cgiapp project, based on my current
> frustration/itch: a test module.
> 
> I've been all over the board with testing and I've identified four major
> methods:
> 
> 1) Interface directly w/ the cgiapp
> 2) Write a www-mech script to interface w/ public web server
> 3) Ditto as #2, but interface with HTTP::Server::Simple::CGI
> 4) Ditto as #2, but interface with Apache::Test
> 
> There are advantages and disadvantages to each, but here's what's
> important to me:
> 
> A) Convenience of www-mech
> B) Coverage reporting
> C) Debugging
> 
> So #1 is great for B & C, but not A.  

> #'s 2-4 are great for A, but not B
> & C.  

I have done B and C with 2 & 4 many times. You just need to work with
setting up Devel::Cover and in extra.conf.in and modperl_extra.pl (or
your startup.pl under #2). If you need more infor on this, just let me
know :)

> After some thought, I think I have the solution and am posing it
> here:
> 
> How about a module that offers the easy-to-use www-mech interface, but
> underneath the layers, it will NOT use a web server, but instead,
> translate the request to a CGI/query object and interface directly w/
> the cgiapp?

I like this idea. Even though I'm a huge fan of Apache::Test, there are
times when it's not appropriate. However, there are many projects where
just testing the code is not enough. Server configuration also needs to
be tested.

> The Catalyst project offers something like this, through a subclass of
> Test::WWW::Mechanize.
> 
> A test script could look something like this:
> 
> use Test::WWW::Mechanize::CGIApp;
> use Test::More qw( no_plan ); # not yet
> 
> my $mech = Test::WWW::Mechanize::CGIApp->new();
> $mech->set_cgiapp( 'My::CGIApp' );
> $mech->get( 'http://localhost/' );

I would think that something like:
  $mech->set_hostname('localhost');

would be more appropriate. Some applications will have hostnames in
their actual HTML so being able to follow links from there would be nice.

I would also think you might need some sort of module => URL mapper and
also something that would work with instance scripts instead of just
modules. Something like this maybe:

  $mech->map_urls(
    'http://localhost/index.cgi'   => 'App::Main',
    'http://localhost/search.cgi'  => 'App::Search',
    'http://localhost/puchase.cgi' => 'App::Purchase',
    'http://localhost/cart.cgi'    => '/bin/cart.cgi',
  );

> # this would translate to the default runmode -- could also use
> $mech->get( 'http://localhost?rm=other_runmode' );
> 
> Anyway, just wanted to throw this out there and see if there was any
> interest.  I have a rough skeleton going, but would love to get some
> expert help (the Catalyst project does this with some complex globbing,
> it looks like, which is a little over my head).

-- 
Michael Peters
Developer
Plus Three, LP


---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to