Test::Usage 0.07 review

Download
by rbytes.net on

Test::Usage is a different approach to testing: selective, quieter, colorful. SYNOPSIS Let's say we are building module Foo.pm

License: Perl Artistic License
File size: 16K
Developer: Luc St-Louis
0 stars award from rbytes.net

Test::Usage is a different approach to testing: selective, quieter, colorful.

SYNOPSIS

Let's say we are building module Foo.pm. To exercise it, we write a usage examples module, Foo_T.pm, which may eventually look something like this:

package Foo_T;
use Test::Usage;
use strict;
use warnings;
use Foo;

example('e1', sub { ... ok(...); ... die "Uh oh"; ... });
example('a1', sub { ... ok(...) or diag(...); ... });
example('a2', sub { ... ok(...); ... });
example('a3', sub {
my $f = Foo->new();
my $got_foo = $f->foo();
my $exp_foo = 'FOO';
ok(
$got_foo eq $exp_foo,
"Expecting foo() to return '$exp_foo'.",
"But got '$got_foo'."
);
});
Here are a few ways to test its examples:
# Run example 'a3' only.
perl -MFoo_T -e 'test(a => "a3")'

# Run all examples whose label matches glob 'a*': a1, a2, a3.
perl -MFoo_T -e 'test(a => "a*")'

# Run all examples found in the test module.
perl -MFoo_T -e test

# Run example 'a3', reporting successes also, but without color.
perl -MFoo_T -e 'test(a => "a3", v => 2, c => 0)'

# Run and summarize all examples in all "*_T.pm" files found under
# current directory.
perl -MTest::Usage -e files

Requirements:
Perl

Test::Usage 0.07 search tags