On Feb 20, 2007, at 9:12 AM, Ovid wrote:
Here's a common enough problem that I assume someone else has solved
it.
[snip]
The idea is, in this scope, we'd convert the 'get_ok' and
'content_like' methods to *not* be tests for the current scope. This
allows us to use our tests as test fixtures rather than duplicate this
logic.
I think this is a horribly clumsy idea, but the above is a simplified
example and some test data could get hairy to setup and if we change
our Web pages, I'd hate to find all of the duplicated logic for
setting
up this test data and testing that it actually works (note that we
could be testing a remote server and not always be in a position to
access the database directly).
Thoughts?
Cheers,
Ovid
Clever and scary. The following is a much more straightforward
alternative, but heavier weight:
sub add_user : Tests(5) {
my $test = shift;
my $mech = $test->mech;
$mech->get( $add_user_page );
ok($mech->success, 'get the "Add User" page') if $testing;
...
}
That is, unwrap the Test::WWW::Mech stuff for this case. That's
duplicating some T::W::M code, but it won't make anybody's head
explode trying to read the test code a couple years down the road.
Chris
--
Chris Dolan, Equilibrious LLC, http://equilibrious.net/
Public key: http://chrisdolan.net/public.key
vCard: http://chrisdolan.net/ChrisDolan.vcf