Test::Kit 2.0 
custom test modules with the features you want 
Alex Balhatchet @ YAPC::EU 2014, София България
Test::Kit
Creating your Kit
Creating your Kit 
package MyProject::Test; 
use Test::Kit;
Creating your Kit 
package MyProject::Test; 
use Test::Kit; 
# Combine multiple modules' behaviour into one 
include 'Test...
Creating your Kit 
package MyProject::Test; 
use Test::Kit; 
# Combine multiple modules' behaviour into one 
include 'Test...
Creating your Kit 
package MyProject::Test; 
use Test::Kit; 
# Combine multiple modules' behaviour into one 
include 'Test...
Creating your Kit 
package MyProject::Test; 
use Test::Kit; 
# Combine multiple modules' behaviour into one 
include 'Test...
Using your Kit
Using your Kit 
use strict; 
use warnings; 
use MyProject::Test tests => 4;
Using your Kit 
use strict; 
use warnings; 
use MyProject::Test tests => 4; 
ok 1, "1 is true"; 
like_string( 
`cat /usr/s...
Using your Kit 
use strict; 
use warnings; 
use MyProject::Test tests => 4; 
ok 1, "1 is true"; 
like_string( 
`cat /usr/s...
Using your Kit 
use strict; 
use warnings; 
use MyProject::Test tests => 4; 
ok 1, "1 is true"; 
like_string( 
`cat /usr/s...
Using your Kit 
use strict; 
use warnings; 
use MyProject::Test tests => 4; 
ok 1, "1 is true"; 
like_string( 
`cat /usr/s...
Why?
Destroy Boilerplate 
1322 files changed, 
2325 insertions(+), 
7549 deletions(-)
More consistency 
Test::MockModule vs 
Test::MockObject::Extends 
Test::NoWarnings vs Test::FailWarnings 
Test::Exception ...
Add behaviour to all tests 
binmode Test::More->builder->output, ":encoding(utf8)"; 
binmode Test::More->builder->failure_...
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 conti...
Give it a go 
:-)
Upcoming SlideShare
Loading in …5
×

Test Kit 2.0 YAPC::EU 2014 Lightning Talk

497 views
444 views

Published on

A five minute introduction to using the Test::Kit module to bundle testing modules together, and why you might want to do that.

Published in: Software
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
497
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
1
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Test Kit 2.0 YAPC::EU 2014 Lightning Talk

  1. 1. Test::Kit 2.0 custom test modules with the features you want Alex Balhatchet @ YAPC::EU 2014, София България
  2. 2. Test::Kit
  3. 3. Creating your Kit
  4. 4. Creating your Kit package MyProject::Test; use Test::Kit;
  5. 5. Creating your Kit package MyProject::Test; use Test::Kit; # Combine multiple modules' behaviour into one include 'Test::More'; include 'Test::LongString';
  6. 6. Creating your Kit package 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' }, };
  7. 7. Creating your Kit package 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' ], };
  8. 8. Creating your Kit package 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' ], };
  9. 9. Using your Kit
  10. 10. Using your Kit use strict; use warnings; use MyProject::Test tests => 4;
  11. 11. Using your Kit use 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" );
  12. 12. Using your Kit use 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";
  13. 13. Using your Kit use 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';
  14. 14. Using your Kit use 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';
  15. 15. Why?
  16. 16. Destroy Boilerplate 1322 files changed, 2325 insertions(+), 7549 deletions(-)
  17. 17. More consistency Test::MockModule vs Test::MockObject::Extends Test::NoWarnings vs Test::FailWarnings Test::Exception vs Test::Fatal
  18. 18. 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)";
  19. 19. Upcoming Changes...
  20. 20. Test::Builder is changing!
  21. 21. Test::Kit is changing! ● New release of Test::Kit coming soon ● Will work with new and old Test::Builder ● Should continue to just work!
  22. 22. Give it a go :-)

×