Upload
alex-balhatchet
View
169
Download
0
Embed Size (px)
DESCRIPTION
A five minute introduction to using the Test::Kit module to bundle testing modules together, and why you might want to do that.
Citation preview
Test::Kit 2.0custom test modules with the features you want
Alex Balhatchet @ YAPC::EU 2014, София България
Test::Kit
Creating your Kit
Creating your Kitpackage MyProject::Test;
use Test::Kit;
Creating your Kitpackage MyProject::Test;
use Test::Kit;
# Combine multiple modules' behaviour into one include 'Test::More';include 'Test::LongString';
Creating your Kitpackage MyProject::Test;
use Test::Kit; # Combine multiple modules' behaviour into one include 'Test::More';include 'Test::LongString'; # Exclude or rename exported subs include 'Test::Warn' => { exclude => [ 'warning_is' ], renamed => { 'warning_like' => 'test_warn_warning_like' },};
Creating your Kitpackage MyProject::Test;
use Test::Kit; # Combine multiple modules' behaviour into one include 'Test::More';include 'Test::LongString'; # Exclude or rename exported subs include 'Test::Warn' => { exclude => [ 'warning_is' ], renamed => { 'warning_like' => 'test_warn_warning_like' },}; # Pass parameters through to import() directly include 'List::Util' => { import => [ 'min', 'max', 'shuffle' ],};
Creating your Kitpackage MyProject::Test;
use Test::Kit; # Combine multiple modules' behaviour into one include 'Test::More';include 'Test::LongString'; # Exclude or rename exported subs include 'Test::Warn' => { exclude => [ 'warning_is' ], renamed => { 'warning_like' => 'test_warn_warning_like' },}; # Pass parameters through to import() directly include 'List::Util' => { import => [ 'min', 'max', 'shuffle' ],};
Using your Kit
Using your Kituse strict;use warnings; use MyProject::Test tests => 4;
Using your Kituse strict;use warnings; use MyProject::Test tests => 4; ok 1, "1 is true"; like_string( `cat /usr/share/dict/words`, qr/^ kit $/imsx, "kit is a word");
Using your Kituse strict;use warnings; use MyProject::Test tests => 4; ok 1, "1 is true"; like_string( `cat /usr/share/dict/words`, qr/^ kit $/imsx, "kit is a word"); test_warn_warning_like { warn "foo";}qr/FOO/i,"warned foo";
Using your Kituse strict;use warnings; use MyProject::Test tests => 4; ok 1, "1 is true"; like_string( `cat /usr/share/dict/words`, qr/^ kit $/imsx, "kit is a word"); test_warn_warning_like { warn "foo";}qr/FOO/i,"warned foo"; is max(qw(1 2 3 4 5)), 5, 'maximum is 5';
Using your Kituse strict;use warnings; use MyProject::Test tests => 4; ok 1, "1 is true"; like_string( `cat /usr/share/dict/words`, qr/^ kit $/imsx, "kit is a word"); test_warn_warning_like { warn "foo";}qr/FOO/i,"warned foo"; is max(qw(1 2 3 4 5)), 5, 'maximum is 5';
Why?
Destroy Boilerplate
1322 files changed, 2325 insertions(+), 7549 deletions(-)
More consistency
Test::MockModule vsTest::MockObject::Extends
Test::NoWarnings vs Test::FailWarnings
Test::Exception vs Test::Fatal
Add behaviour to all tests
binmode Test::More->builder->output, ":encoding(utf8)";binmode Test::More->builder->failure_output, ":encoding(utf8)";binmode Test::More->builder->todo_output, ":encoding(utf8)";
Upcoming Changes...
Test::Builder is changing!
Test::Kit is changing!
● New release of Test::Kit coming soon
● Will work with new and old Test::Builder
● Should continue to just work!
Give it a go :-)