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)

Tuesday August 12, 2008
08:15 AM

Test::Kit

[ #37163 ]

It's not on the CPAN yet, but it allows you to easily write your own testing modules based on CPAN test modules.

package My::Test::REST;

use Test::Kit qw(
    Test::More
    Test::XML
    Test::JSON
);

sub import {
    my $callpackage = caller(0);
    Test::Kit->export_to($callpackage);
}

1;

And then in your test code:

use My::Test::Rest;

# all functions from Test::More, Test::XML and Test::JSON are available

What if two functions define the same test name? You'll get a compile time failure listing which functions are defined in which modules. As a result, I've basically implemented Perl 6 roles for functions.

use Test::Kit
    'Test::More',
    'Test::Naughty' => { rename => { ok => 'naughty_ok' } },
    'Test::VeryBad' => { exclude => ['very_bad_test'] };

I'm now working on 'features' which allows for custom testing features like failure callbacks and 'explain'.

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.
  • Shouldn't you make this code more general by renaming it? Does it add extra test functionality? If not maybe you should rename it to ... Sorry, I don't have any inspiration.
    • I'm not sure I follow you. I chose "kit" based on the definition "a set of materials or parts from which something can be assembled" and this allows you to treat other test module functions as "parts" which you can then reassemble to fit your own testing needs. That seems to fit "kit" very well. I'm adding new features to it now to allow me to rewrite Test::Most [cpan.org] with Test::Kit as the foundation and this further extends the "kit" metaphor. If I'm missing something really obvious, feel free to hit me with

      • You said:

        As a result, I've basically implemented Perl 6 roles for functions.

        If your module is this general, you could rename it to something so it isn't as associated with testing. Like Perl6::Role or Function::Import or something similar. Of course, using Kit is a good idea.

      • "Test::Toolkit" - alliteration FTW!