[Catalyst-dev] RFC: Catalyst::Test::LocalContext

Sebastian Willert willert at gmail.com
Tue Sep 18 22:26:28 GMT 2007


On Tue, 2007-09-18 at 21:37 +0100, Matt S Trout wrote:
> On Tue, Sep 18, 2007 at 01:32:03AM +0200, Sebastian Willert wrote:
> > Hi all,
> > 
> > I often found myself wanting to test some internal aspects of my request
> > handling in Catalyst or were to lazy to check the full returned HTML and
> > rather just inspect the stack.
> > 
> > For this purpose I expanded Catalyst::Test and threw away its remote
> > functionality. So without further ado, I'd like to ask for your comments
> > on this idea/module/name. POD follows.
> 
> The $c mocking stuff should be separate so it can be used for unit testing.

I don't really mock that much, basically I just split
Catalyst::Test::local_request after the prepare and do some namespace
trickery to keep the HTTP::Request::AsCGI stuff accessible. Actually
I've experimented with mocking $c, but this turned out unyielding for a
general purpose test helper. There are to many plugins around that would
all need special preparation that your far better of just sticking to
the established context setup and fake the request instead of the
context.

> The "test $c afterwards" stuff, maybe it should be possible to throw a
> Dumper-isation of $c over the wire or something.

To support both local and remote requests within this module? I doubt
so. Just for starters you can't even be sure that the dump would be
re-parsed correctly because of different module versions, unavailability
of certain modules, stuff like that, and it can't really be done without
modifying the app to be tested. Additionally I have the gut feeling that
access to the context before it is dispatched is nearly as useful as
getting it after the fact. And this would be impossible to do over the
wire.

> More interestingly, does anybody ever actually use the remote stuff in ::Test
> directly?

Just a few days ago while patching up some test cases in trunk ;) apart
from this, I've never done so before and I doubt I ever will.

Cheers,
  Sebastian




More information about the Catalyst-dev mailing list