Perl and testing libraries…! tokuhirom YAPC::Asia 2014
Perl and testing libraries…!
tokuhirom YAPC::Asia 2014
Conclusion
You should try Test::Kantan
Self introduction
Server side Web engineer
Amon2
Localizer
MadEyeArcher
CarolineDifflet
Furl
Docopt SQL::MakerHTTP::Session2
FormValidator::Lite
mobirc
Test::SharedFork Test::Pretty Test::TCP
If you have any questions around the modules, you can ask me after this talk.
Do you like testing?
Do you like TDD?
Then…
History of Perl testing libraries…!
Test::More, Test::Class
Test::More
use Test::More tests => 1;
ok(“dan” eq “kogai”);
Test::Class
ArchitectureTest::Builder
Test::More Test::Class Test::Exceptions
etc…
Test::Builder
• Counts number of tests
• Counts number of Failures
• Counts number of Succeeded.
TAP!
Test Anything Protocol
Latest enhancements
• subtest • done_testing
subtest 'feature2', sub { ok 1, 'it works'; ok 0, 'it looks great'; }; done_testing;
TAP with prove
prove eats TAP
Test::Builder is evolving…
Test::Builder2
• It may started at 2011. • With dreams…
TB2
• Custom output • Full rewrite • OO-ish APIs
But…
We need workaround for now…!
Test::Pretty 爆誕
Pretty output without code modifications!
めっちゃ見やすい!!
How it works?
Monkey patching…
But it works. Maybe.
It’s not a big problem. Because this is a
workaround for now.
Test::Ika
RSpec like testing framework for Perl5
Ika?
Ika =
Please check it, if you love RSpec.
Test::More の停滞 Development has stagnated
Test::Builder2
• It may started at 2011. • With dreams… • It was gone. ← NEW!
Test::More x.xx was released.
Then…
I can’t wait evolution.
Test::Kantan 爆誕
Yet another testing framework
Test::Kantan is not based on Test::Builder
What’s new?
subtests with hooks
before_each after_each
jasmine inspired interfaces.
IIRC
BDD Style
Given-When-Then
Plain old Test::More style
Assertions
ok { $foo->bar() eq ‘baz’ };
Power Assert hooks B optree.
ok { x(x($foo)->bar()) eq ‘baz’ };
expect($x)->to_be_true;
Shows testing details if it’s failed.
All or nothing. pass or die;
Conclusion
Conclusion
• Test::SharedFork
• Test::TCP
• Test::Pretty
• Test::Ika
• Test::Kantan ← NEW!
Enjoy testing!
Thanks