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 August 14, 2008
06:24 AM

Test::Kit

[ #37181 ]

Doing more work with Test::Kit and now you can do this:

package My::Tests;

use Test::Kit
  'Test::More' => {
    exclude => 'is_deeply', # force use of eq_or_diff
  },
  'Test::Differences' => {
    rename => {
      eq_or_diff => 'is_deeply',
    },
  },
  'Test::Exception',
  '+explain',
  '+on_fail';

sub BUILD {
    # completely optional
    # only needed if you want to extend with your own behavior
    my ( $class, @args ) = @_;
    # your own custom extensions, and return @args or a new
    # import list
    return @your_new_import_list;
}

And in your code:

use My::Tests 'no_plan';
on_fail {
    my $test = shift;
    if ( $test->name =~ /critical/i ) {
        my $message = sprintf "Test %s failed at %s line %d package %s" =>
          $test->name,
          $test->file,
          $test->line,
          $test->package;
        email_admin($message);
    }
};

is_deeply $foo, $bar, 'Uses eq_or_diff internally';
explain $baz;  # if it's a reference, uses Data::Dumper
throws_ok { some_func() }
  qr/some message/, 'some_func() is hateful';

So now you can set your own callbacks for test failures and do anything you really need. You can mix and match your own test modules. You can automatically dump references with explain. You can easily extend it. You can choose which test functions you do or do not want or rename them. Conflicting test functions fail at compile time. Yada, yada, yada.

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.