Test::Kit

Ovid on 2008-08-12T13:15:31

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'.


Rename it to something more general

pstuifzand on 2008-08-12T14:43:55

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.

Re:Rename it to something more general

Ovid on 2008-08-12T15:01:08

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 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 a clue stick :)

Re:Rename it to something more general

pstuifzand on 2008-08-12T15:35:28

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.

Re:Rename it to something more general

hex on 2008-08-12T23:18:30

"Test::Toolkit" - alliteration FTW!

Re:Rename it to something more general

hex on 2008-08-12T23:19:41

ps just kidding, your module sounds hawt.