SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
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!

Weitere ähnliche Inhalte

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Mehr von 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
 

Mehr von 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
 

Kürzlich hochgeladen

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZABSYZ Inc
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfYashikaSharma391629
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Rob Geurden
 
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
 
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
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
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
 
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
 
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
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
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
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...confluent
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfStefano Stabellini
 
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
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfFerryKemperman
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)jennyeacort
 

Kürzlich hochgeladen (20)

Salesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZSalesforce Implementation Services PPT By ABSYZ
Salesforce Implementation Services PPT By ABSYZ
 
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdfInnovate and Collaborate- Harnessing the Power of Open Source Software.pdf
Innovate and Collaborate- Harnessing the Power of Open Source Software.pdf
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...Simplifying Microservices & Apps - The art of effortless development - Meetup...
Simplifying Microservices & Apps - The art of effortless development - Meetup...
 
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
 
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...
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
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
 
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
 
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
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Cloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEECloud Data Center Network Construction - IEEE
Cloud Data Center Network Construction - IEEE
 
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
Catch the Wave: SAP Event-Driven and Data Streaming for the Intelligence Ente...
 
Xen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdfXen Safety Embedded OSS Summit April 2024 v4.pdf
Xen Safety Embedded OSS Summit April 2024 v4.pdf
 
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
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Introduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdfIntroduction Computer Science - Software Design.pdf
Introduction Computer Science - Software Design.pdf
 
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
Call Us🔝>༒+91-9711147426⇛Call In girls karol bagh (Delhi)
 

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