Test::Tiny -- Write simple tests, simply.
use Test::Tiny tests => NUMBER; ok(TEST [, MESSAGE]); # pass if TEST is true, and print MESSAGE show(TEST); # pass if eval(TEST) is true, print TEST SKIP: { skip(MESSAGE, N); # skip this code, including N tests } BAIL_OUT([MESSAGE]); # give up, printing MESSAGE.
I thought Test::Simple was simple, but then I realized it relies on Test::Builder to implement the one function it exports. Test::Tiny does more with less:
ok(TEST [, MESSAGE])
Print "ok N - MESSAGE" if TEST is true, and "not ok N - MESSAGE" otherwise. The MESSAGE is optional.
"ok N - MESSAGE"
TEST
"not ok N - MESSAGE"
MESSAGE
show(EXPRESSION)
show is like ok, but uses eval(EXPRESSION) as the TEST, and uses EXPRESSION as the MESSAGE. This is useful when your test is self-explanatory:
show
ok
eval(EXPRESSION)
EXPRESSION
ok sqrt(4) == 2, 'sqrt(4) is 2'; # redundant show 'sqrt(4) == 2'; # non-redundant
skip(MESSAGE, NUMBER)
Skip NUMBER tests with reason MESSAGE:
NUMBER
SKIP: { skip "message", $number; # tests go here. }
BAIL_OUT(REASON)
Stop testing for REASON.
REASON
done_testing
Indicate that you finished running your tests.
Test::Simple, Test::More, Test::Builder.
Sean O'Rourke <seano@cpan.org>.
<seano@cpan.org>
Bug reports welcome, patches even more welcome.
Test::Tiny doesn't try to be 100% compatible with Test::Simple, but should stay clean, clear, and under 5% of Test::Simple's lines (from Simple.pm, Builder.pm, and files in @INC/Builder). Current counts are:
Test::Tiny 52 SLOC, 144 lines Test::Simple 1345 SLOC, 3612 lines
Copyright (C) 2010, 2011, Sean O'Rourke. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::Tiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Tiny
CPAN shell
perl -MCPAN -e shell install Test::Tiny
For more information on module installation, please visit the detailed CPAN module installation guide.