Phil Lawrence on 28 Jul 2004 13:22:40 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: Web page testing


Cc: ABE.pm
Cc: Philly.pm

Ricardo SIGNES wrote:

> * Phil Lawrence
>
>> Anyway, why not have:
>> ./t
>> ./t/modules
>> ./t/modules/login.pm
>> [ ... ]
>
>
>
> ...why not indeed? :)   That's probably what I'd do, if I had

> a lot of repeated stuff, too.

Here's why not: I can't use Test::More from within those modules, because I already used it in the ./t/test_driver.pl script! :-(

I wasted yesterday looking for a way to do this, and the best I could do by 5:00 was find references to Test::Builder, whose constructor returns singletons. I think this may help, but I'm not sure about implementation. Ideas? Basically, I need the ability to write tests into each module.

The last thing I tried was to subclass Test::More thusly:
  package T::Test;
  use warnings;
  use strict;
  use Test::More qw(no_plan);
  sub new { bless {} => shift() }
  1;

and in ./t/test_driver.pl:
  use T::Test;
  my $t = T::Test->new;
  $t->require_ok( 'Term::Interact' );

If this worked, I thought I could pass $t to all the different testing modules I use from the driver script. But no dice:

  $ ./t/test.pl
  not ok 1 - require T::Test=HASH(0x81392a0);
  #     Failed test (./t/test.pl at line 11)
  #     Tried to require 'T::Test=HASH(0x81392a0)'.
  #     Error:  Can't modify require in scalar assignment
        at (eval 2)   line 2, at EOF
  1..1
  # Looks like you failed 1 tests of 1.

This may be related to Test::Builder's export_to_level method, I don't know. I'm not thinking clearly about this...

Phil

-
**Majordomo list services provided by PANIX <URL:http://www.panix.com>**
**To Unsubscribe, send "unsubscribe phl" to majordomo@lists.pm.org**