SlideShare una empresa de Scribd logo
1 de 32
Descargar para leer sin conexión
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!

Más contenido relacionado

Destacado

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
 

Destacado (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 a Test::Kit 2.0 (London.pm Technical Meeting July 2014)

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 a Test::Kit 2.0 (London.pm Technical Meeting July 2014) (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
 

Más de 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
 

Más de 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
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 

Último (20)

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 

Test::Kit 2.0 (London.pm Technical Meeting July 2014)

  • 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