[Catalyst] testing catalyst app - need context
Kate Yoak
kate at yoak.com
Sun Mar 1 21:25:33 GMT 2009
Hi there,
Here is a newbie question:
I like to test my functionality in bits and pieces as I write it. How
do I go about getting myself the context object in a test script?
For example, one of the tests catalyst installs is t/model_App.t where
it loads the model. I'd love to then be able to use the model the same
way a controller would:
my $acc = $c->model('Account')->find(1);
Instead, I am doing
my $model = MyApp::Model::App->new();
my $acc = $model->recordset('Account')->find(1);
In addition to being less than ideal because I am doing something
different that I expect real application code to do, it presents
configuration problems. Like, turns out, in order for config to take
effect, I have to run __PACKAGE__->setup; after configuring it - which
won't be necessary, I think, in a real app.
Is the practice of unit tests that break up the layers of catalyst
frowned upon? Or what should I do to make it work right?
Thanks for the help!
Cheers,
Kate
More information about the Catalyst
mailing list