Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Thursday March 08, 2007
06:08 AM

My New Custom Test::More

[ #32614 ]

I've finally gotten around to customizing my Test::More a bit more:

package My::Test::More;

use Test::Builder::Module;
@ISA = qw(Test::Builder::Module);
use Test::More;
use Test::Differences;
use Test::Exception;

INIT {
    unless ( exists $INC{'Test/Class.pm'} ) {

        # NoWarnings doesn't play well with Test::Class
        eval "use Test::NoWarnings";
    }
}

@EXPORT = (
    @Test::More::EXPORT,
    @Test::Differences::EXPORT,
    @Test::Exception::EXPORT,
);

$ENV{RUNNING_TESTS} = 1;

1;

I use Test::Differences and Test::Exception constantly and I was getting tired of "use"ing them in every test program, so now I don't have to. Using this means you automatically get an extra test from Test::NoWarnings, but now you can't forget to have it :)

I should write some code to avoid function name conflicts in @EXPORT. Maybe even to rename or exclude them. Think 'traits' for functions :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • for getting me started on doing this. :-)

    [repeated from the qa list]

    I think it was you or someone else who got me started on this in Handel
    and my other DBIC based dists where I needed both Test::More and custom
    sqlite t/var initializer junk:

    http://search.cpan.org/src/CLACO/DBIx-Class-InflateColumn-Currency-0.01/t/lib/DB IC/Test.pm [cpan.org]

    Yup, in fact, you're still in the comments... :-)

    package DBIC::Test;
    use strict;
    use warnings;
     
    BEGIN {
        # little trick by Ovid to pretend to subclass+exporter Test

    • You know, up until this post, I never realized that you and Chris Laco were one and the same. How the hell did I miss that? :)

  • @EXPORT = (
        @Test::More::EXPORT,
        @Test::Differences::EXPORT,
        @Test::Exception::EXPORT,
    );
    I've wanted a re-exporting solution before, but had never seen or thought of something this simple and clear. Thanks for sharing that!

     Mark

    • I love moments like that. You get so knee deep in perl, oop, orms, forms, code and such. Then along comes a few lines of dead obvious code and the light bulb goes on.