httpd-test-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stas Bekman <>
Subject Re: Test::More backend support
Date Mon, 26 Apr 2004 18:54:53 GMT
Geoffrey Young wrote:
> hi all
> I've managed to figure out at least preliminary support for using Test::More
> as the backend for Apache::Test.  attached is a patch as well as a tarball
> that uses a few Test::More features in it.  I may have missed a few of the
> finer features of Test::More, but it seems to do what I need it to, namely
> allowing the use of Test::More from server-side (t/response/TestFoo/
> tests as well as allowing the existing mod_perl-2.0 test suite to run unaltered.
> feedback welcome.

looks nice.

Here is the feedback:

I'd replace $plan with *plan:

+        eval {
+            require Test::More;
+            *plan = \&Test::More::plan;
+        } or die "-withtestmore error: $@";
+    else {
+        # the default - support
+        require Test;
+        Test->import(qw(ok skip));
+        *plan = \&Test::plan;
+    }
+ plan(@_, @testmore);

or even better, since you can import plan() anyway, just use a forward 

use subs qw(plan);

and then you don't need any new vars or mess with aliases. it'll be just 
there. which will make your code much simpler:

   eval { require Test::More } or die "-withtestmore error: $@";
   require Test;

which can be shrinked even further and have things much simpler: just figure 
which class you are going to use, load it and then import:


since you die anyway with eval above.


and one more nit -- The import() function may be called more than once, and 
every time it'll try to reimport all these symbols. So you probably want to 
have a flag so that you import them only once.

Also what happens if -withtestmore is not the first argument to import()?


Regarding this comment:

+C<-withtestmore> tells I<Apache::Test> to use the I<Test::More> framework
+instead of the I<> framework behind the scenes.  Note that you are
+not required to C<use Test::More> yourself with the C<-withtestmore> option.

What happens if I want to use functions from T-M, will this work?

use Apache::Test qw(-withtestmore);
is ($foo, $bar);

I guess not. Usually you want Test::More for its functionality, not 
ok/plan/skip. So in 99.9% cases you will want to say:

use Apache::Test qw(-withtestmore);
use Test::More;
is ($foo, $bar);



+        Test::Builder->failure_output(\*STDOUT);

I think has it set to STDERR: $TESTERR = *STDERR{IO};

so we probably want to keep things consistent, no?

Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker     mod_perl Guide --->

View raw message