Test::Base::SubTest - Enables Test::Base to use subtest
use Test::Base::SubTest; filters { input => [qw/eval/] }; run { my $block = shift; is $block->input, $block->expected, $block->name; }; done_testing; __DATA__ ### subtest 1 === test 1-1 --- input: 4*2 --- expected: 8 === test 1-2 --- input : 3*3 --- expected: 9 ### subtest 2 === test 2-1 --- input: 4*3 --- expected: 12
Test::Base::SubTest is a extension of Test::Base::Less.
"### TEST NAME" is a delimiter of a subtest. Indentaion is necessary.
This module exports all Test::More's exportable functions, and following functions:
filters { input => [qw/eval/], };
Set a filter for the section name.
run { my $block = shift; is $block->input, $block->expected, $block->name; };
Calls the sub for each block. It passes the current block object to the subroutine.
run_is input => 'expected';
Register a filter for $name using $code.
This module provides only few filters. If you want to add more filters, pull-reqs welcome. (I only merge a patch using no depended modules)
eval() the code.
chomp() the arguments.
chomp()
uc() the arguments.
uc()
Remove extra blank lines from the beginning and end of the data. This allows you to visually separate your test data with blank lines.
You can register your own filter by following form:
use Digest::MD5 qw/md5_hex/; Test::Base::Less::register_filter(md5_hex => \&md5_hex);
You can use a CodeRef as filter.
use Digest::MD5 qw/md5_hex/; filters { input => [\&md5_hex], };
Most of code is taken from Test::Base::Less. Thank you very match, tokuhirom.
Hiroki Honda <cside.story@gmail.com>
Copyright (C) Hiroki Honda
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Test::Base::SubTest, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Base::SubTest
CPAN shell
perl -MCPAN -e shell install Test::Base::SubTest
For more information on module installation, please visit the detailed CPAN module installation guide.