SlideShare a Scribd company logo
1 of 32
Download to read offline
Test::Kit 2.0
custom test modules with the features you want
Alex Balhatchet @ London.pm Technical Meeting, July 2014
Hi there!
Hi there!
● Alex Balhatchet
● CTO at Nestoria
● Big fan of London.pm technical meetings
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::More';
include 'Test::LongString';
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'
},
};
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' ],
};
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' ],
};
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/share/dict/words`,
qr/^ kit $/imsx,
"kit is a word"
);
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";
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';
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';
2.0
2.0
● 0.101 was written by Ovid
● Really cool idea!
● Unfortunately broken…
○ Didn’t work with Test::Aggregate
○ Only worked in package main
○ Complicated “features” architecture
2.0
● Saw Matt Trout talk about Import::Into at
LPW 2013
● Realised it probably solved half the problems
with Ovid’s Test::Kit
● Rewrote it from scratch as Test::Kit2
● Got COMAINT from Ovid so I could release
it as Test::Kit 2.0
Why use Test::Kit?
● Reduce boilerplate
● Be more consistent
● Easily add behaviour to all your tests
● 1322 files changed,
2325 insertions(+),
7549 deletions(-)
Nestoria Kit
The Nestoria Kit
# basics
include 'Test::More';
# outputs, warnings and exceptions
include 'Test::FailWarnings', 'Test::Warn',
'Test::Exception', 'Test::Output';
# files, data and data structures
include 'Test::File', 'Test::LongString', 'Test::JSON';
include 'Test::Deep' => { 'exclude' => [ qw(all any) ] };
The Nestoria Kit
# mocking
include 'Test::MockObject', 'Test::MockObject::Extends',
'Test::MockModule';
# utilities
include 'Data::Dumper';
The Nestoria Kit
binmode Test::More->builder->output, ":encoding(utf8)";
binmode Test::More->builder->failure_output, ":encoding(utf8)";
binmode Test::More->builder->todo_output, ":encoding(utf8)";
The Nestoria Kit
{
my @req_env_vars = (
'LOKKU_CODE',
'LOKKU_COMMON',
'LOKKU_BIGSLOW',
);
foreach my $env_var (@req_env_vars) {
if(!$ENV{$env_var}) {
die "Environment variable '$env_var' not set";
}
}
}
Actively
Maintained!
import::Into 1.002003
● Changed behaviour
● Flagged up as failures on CPAN Testers
● Test::Kit 2.01 released 2 days later
Test::Builder 1.301001_013
● Dev release of Test::Builder!
● Test::Builder::Module deprecated
● Again, flagged on CPAN Testers
● Not fixed yet, but will be very soon
See Also
See Also
● ToolSet
● Import::Base
● Import::Into
● Test::Builder::Provider
Questions?
N
estoria
is
H
iring!
http://lokku.com
/jobs
Thanks!

More Related Content

Viewers also liked

Alsis Cierra Alsis Mexico Opportunities Fund
Alsis Cierra Alsis Mexico Opportunities FundAlsis Cierra Alsis Mexico Opportunities Fund
Alsis Cierra Alsis Mexico Opportunities FundDavid Sanchez-Tembleque
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Alex Balhatchet
 
Nestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning TalkNestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning TalkAlex Balhatchet
 
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyoyoyamasaki
 
App::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter appApp::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter appAlex Balhatchet
 
AppSec And Microservices
AppSec And MicroservicesAppSec And Microservices
AppSec And MicroservicesSam Newman
 

Viewers also liked (6)

Alsis Cierra Alsis Mexico Opportunities Fund
Alsis Cierra Alsis Mexico Opportunities FundAlsis Cierra Alsis Mexico Opportunities Fund
Alsis Cierra Alsis Mexico Opportunities Fund
 
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
Introduction to Writing Readable and Maintainable Perl (YAPC::EU 2011 Version)
 
Nestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning TalkNestoria Dev Blog YAPC::EU 2014 Lightning Talk
Nestoria Dev Blog YAPC::EU 2014 Lightning Talk
 
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
[D14] MySQL 5.6時代のパフォーマンスチューニング *db tech showcase 2013 Tokyo
 
App::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter appApp::highlight - a simple grep-like highlighter app
App::highlight - a simple grep-like highlighter app
 
AppSec And Microservices
AppSec And MicroservicesAppSec And Microservices
AppSec And Microservices
 

Similar to Create custom test modules with Test::Kit 2.0

Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Justin James
 
Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015ice799
 
Continuous integration with Git & CI Joe
Continuous integration with Git & CI JoeContinuous integration with Git & CI Joe
Continuous integration with Git & CI JoeShawn Price
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015ice799
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?Rsquared Academy
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017Ortus Solutions, Corp
 
Puppet Loves RSpec, Why You Should, Too
Puppet Loves RSpec, Why You Should, TooPuppet Loves RSpec, Why You Should, Too
Puppet Loves RSpec, Why You Should, TooPuppet
 
Puppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooPuppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooDennis Rowe
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Andrea Francia
 
Open Atrium (DrupalCon Paris 2009, Day 3)
Open Atrium (DrupalCon Paris 2009, Day 3)Open Atrium (DrupalCon Paris 2009, Day 3)
Open Atrium (DrupalCon Paris 2009, Day 3)Cameron Eagans
 
Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetPuppet
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1Albert Rosa
 
PuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetPuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetWalter Heck
 
PuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetPuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetOlinData
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytestHector Canto
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmusBram Vogelaar
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Gianluca Padovani
 
Martin Aspeli Extending And Customising Plone 3
Martin Aspeli   Extending And Customising Plone 3Martin Aspeli   Extending And Customising Plone 3
Martin Aspeli Extending And Customising Plone 3Vincenzo Barone
 

Similar to Create custom test modules with Test::Kit 2.0 (20)

Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...Nuget is easier than you think and you should be using it as both a consumer ...
Nuget is easier than you think and you should be using it as both a consumer ...
 
Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015Package manages and Puppet - PuppetConf 2015
Package manages and Puppet - PuppetConf 2015
 
Continuous integration with Git & CI Joe
Continuous integration with Git & CI JoeContinuous integration with Git & CI Joe
Continuous integration with Git & CI Joe
 
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
Puppet Camp LA 2015: Package Managers and Puppet (Beginner)
 
Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015Puppet Camp LA 2/19/2015
Puppet Camp LA 2/19/2015
 
How to install & update R packages?
How to install & update R packages?How to install & update R packages?
How to install & update R packages?
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
 
Puppet Loves RSpec, Why You Should, Too
Puppet Loves RSpec, Why You Should, TooPuppet Loves RSpec, Why You Should, Too
Puppet Loves RSpec, Why You Should, Too
 
Puppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, tooPuppet loves RSpec, why you should, too
Puppet loves RSpec, why you should, too
 
Unit Testing in iOS
Unit Testing in iOSUnit Testing in iOS
Unit Testing in iOS
 
Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008Google C++ Testing Framework in Visual Studio 2008
Google C++ Testing Framework in Visual Studio 2008
 
Open Atrium (DrupalCon Paris 2009, Day 3)
Open Atrium (DrupalCon Paris 2009, Day 3)Open Atrium (DrupalCon Paris 2009, Day 3)
Open Atrium (DrupalCon Paris 2009, Day 3)
 
Wrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from PuppetWrangling 3rd Party Installers from Puppet
Wrangling 3rd Party Installers from Puppet
 
Code igniter unittest-part1
Code igniter unittest-part1Code igniter unittest-part1
Code igniter unittest-part1
 
PuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetPuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of Puppet
 
PuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of PuppetPuppetCamp SEA 1 - Use of Puppet
PuppetCamp SEA 1 - Use of Puppet
 
Effective testing with pytest
Effective testing with pytestEffective testing with pytest
Effective testing with pytest
 
Testing your infrastructure with litmus
Testing your infrastructure with litmusTesting your infrastructure with litmus
Testing your infrastructure with litmus
 
Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)Tdd is not about testing (C++ version)
Tdd is not about testing (C++ version)
 
Martin Aspeli Extending And Customising Plone 3
Martin Aspeli   Extending And Customising Plone 3Martin Aspeli   Extending And Customising Plone 3
Martin Aspeli Extending And Customising Plone 3
 

More from Alex Balhatchet

Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014Alex Balhatchet
 
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Alex Balhatchet
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlAlex Balhatchet
 

More from Alex Balhatchet (6)

Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014Geocoding the World in Perl YAPC::EU 2014
Geocoding the World in Perl YAPC::EU 2014
 
Perl 101
Perl 101Perl 101
Perl 101
 
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
Continuous testing and deployment in Perl (London.pm Technical Meeting Octobe...
 
File::CleanupTask
File::CleanupTaskFile::CleanupTask
File::CleanupTask
 
Authoring CPAN modules
Authoring CPAN modulesAuthoring CPAN modules
Authoring CPAN modules
 
Introduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable PerlIntroduction to writing readable and maintainable Perl
Introduction to writing readable and maintainable Perl
 

Recently uploaded

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Developmentvyaparkranti
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf31events.com
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringHironori Washizaki
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEEVICTOR MAESTRE RAMIREZ
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 

Recently uploaded (20)

Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 
VK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web DevelopmentVK Business Profile - provides IT solutions and Web Development
VK Business Profile - provides IT solutions and Web Development
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Sending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdfSending Calendar Invites on SES and Calendarsnack.pdf
Sending Calendar Invites on SES and Calendarsnack.pdf
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Machine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their EngineeringMachine Learning Software Engineering Patterns and Their Engineering
Machine Learning Software Engineering Patterns and Their Engineering
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 

Create custom test modules with Test::Kit 2.0

  • 1. Test::Kit 2.0 custom test modules with the features you want Alex Balhatchet @ London.pm Technical Meeting, July 2014
  • 3. Hi there! ● Alex Balhatchet ● CTO at Nestoria ● Big fan of London.pm technical meetings
  • 6. Creating your Kit package MyProject::Test; use Test::Kit;
  • 7. Creating your Kit package MyProject::Test; use Test::Kit; # Combine multiple modules' behaviour into one include 'Test::More'; include 'Test::LongString';
  • 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' }, };
  • 9. 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' ], };
  • 10. 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' ], };
  • 12. Using your Kit use strict; use warnings; use MyProject::Test tests => 4;
  • 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" );
  • 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";
  • 15. 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';
  • 16. 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';
  • 17. 2.0
  • 18. 2.0 ● 0.101 was written by Ovid ● Really cool idea! ● Unfortunately broken… ○ Didn’t work with Test::Aggregate ○ Only worked in package main ○ Complicated “features” architecture
  • 19. 2.0 ● Saw Matt Trout talk about Import::Into at LPW 2013 ● Realised it probably solved half the problems with Ovid’s Test::Kit ● Rewrote it from scratch as Test::Kit2 ● Got COMAINT from Ovid so I could release it as Test::Kit 2.0
  • 20. Why use Test::Kit? ● Reduce boilerplate ● Be more consistent ● Easily add behaviour to all your tests ● 1322 files changed, 2325 insertions(+), 7549 deletions(-)
  • 22. The Nestoria Kit # basics include 'Test::More'; # outputs, warnings and exceptions include 'Test::FailWarnings', 'Test::Warn', 'Test::Exception', 'Test::Output'; # files, data and data structures include 'Test::File', 'Test::LongString', 'Test::JSON'; include 'Test::Deep' => { 'exclude' => [ qw(all any) ] };
  • 23. The Nestoria Kit # mocking include 'Test::MockObject', 'Test::MockObject::Extends', 'Test::MockModule'; # utilities include 'Data::Dumper';
  • 24. The Nestoria Kit binmode Test::More->builder->output, ":encoding(utf8)"; binmode Test::More->builder->failure_output, ":encoding(utf8)"; binmode Test::More->builder->todo_output, ":encoding(utf8)";
  • 25. The Nestoria Kit { my @req_env_vars = ( 'LOKKU_CODE', 'LOKKU_COMMON', 'LOKKU_BIGSLOW', ); foreach my $env_var (@req_env_vars) { if(!$ENV{$env_var}) { die "Environment variable '$env_var' not set"; } } }
  • 27. import::Into 1.002003 ● Changed behaviour ● Flagged up as failures on CPAN Testers ● Test::Kit 2.01 released 2 days later
  • 28. Test::Builder 1.301001_013 ● Dev release of Test::Builder! ● Test::Builder::Module deprecated ● Again, flagged on CPAN Testers ● Not fixed yet, but will be very soon
  • 30. See Also ● ToolSet ● Import::Base ● Import::Into ● Test::Builder::Provider