SlideShare une entreprise Scribd logo
1  sur  56
Curtis "Ovid" Poe
http://allaroundtheworld.fr/
http://blogs.perl.org/users/ovid/
http://www.slideshare.net/Ovid/testclassmoose
info@allaroundtheworld.fr
info@allaroundtheworld.fr
• 
• 
• 
• 

OO tests for OO code
Nice performance boost
Easy to organize tests
Already use Moose

info@allaroundtheworld.fr
info@allaroundtheworld.fr
1.  Getting started with Test::Class
2.  Inheriting Test::Class tests
3.  Making your testing life easier
4.  Using test control methods
5.  Test::Class tricks
On www.modernperlbooks.com
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
Solution?
✘
✘
✓

Instantiate the object correctly?

info@allaroundtheworld.fr
• 
• 
• 
• 

We've written two classes
We've written two test classes
We've seen test inheritance
… but it broke our test!

info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
•  It works
•  But we constructed our object twice
•  Wash/rinse/repeat for every test method?

info@allaroundtheworld.fr
Method

Phase
Before each test class
Before each test method
After each test method
After each test class

info@allaroundtheworld.fr
• 
• 
• 
• 
• 

Connect to a database (often in startup)
Set up fixtures/transactions (setup)
Clean fixtures/rollbacks (teardown)
Disconnect from database (shutdown)
And more …

info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
• 
• 
• 
• 
• 
• 
• 

Only run API tests
Only run unit tests
Run correct code coverage
Run Jenkins tests
Run DB tests
Create fixtures only if the test needs it
Skip network tests if the network is down

info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
• 
• 
• 
• 

Fine-grained control
xUnit-style testing
Full Moose integration
Reporting

info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
info@allaroundtheworld.fr
?
info@allaroundtheworld.fr

Contenu connexe

Similaire à Test::Class::Moose

Frequently asked questions answered frequently - but now for the last time
Frequently asked questions answered frequently - but now for the last timeFrequently asked questions answered frequently - but now for the last time
Frequently asked questions answered frequently - but now for the last time
Andreas Jung
 
How to ship web software like pirates!
How to ship web software like pirates!How to ship web software like pirates!
How to ship web software like pirates!
Sylvain Carle
 

Similaire à Test::Class::Moose (20)

Foundation selenium java
Foundation selenium java Foundation selenium java
Foundation selenium java
 
Code Review: How and When
Code Review: How and WhenCode Review: How and When
Code Review: How and When
 
Practical IronRuby
Practical IronRubyPractical IronRuby
Practical IronRuby
 
Frequently asked questions answered frequently - but now for the last time
Frequently asked questions answered frequently - but now for the last timeFrequently asked questions answered frequently - but now for the last time
Frequently asked questions answered frequently - but now for the last time
 
Porque VIM?
Porque VIM?Porque VIM?
Porque VIM?
 
Vladimir Primakov - Qa management in big agile teams
Vladimir Primakov - Qa management in big agile teamsVladimir Primakov - Qa management in big agile teams
Vladimir Primakov - Qa management in big agile teams
 
How to ship web software like pirates!
How to ship web software like pirates!How to ship web software like pirates!
How to ship web software like pirates!
 
Dov'è il tasto ok?
Dov'è il tasto ok?Dov'è il tasto ok?
Dov'è il tasto ok?
 
RootedCON 2015 - Deep inside the Java framework Apache Struts
RootedCON 2015 - Deep inside the Java framework Apache StrutsRootedCON 2015 - Deep inside the Java framework Apache Struts
RootedCON 2015 - Deep inside the Java framework Apache Struts
 
Leveling Up at JavaScript
Leveling Up at JavaScriptLeveling Up at JavaScript
Leveling Up at JavaScript
 
Apache Solr - search for everyone!
Apache Solr - search for everyone!Apache Solr - search for everyone!
Apache Solr - search for everyone!
 
Puppet101
Puppet101Puppet101
Puppet101
 
Nif practical
Nif practicalNif practical
Nif practical
 
Selenium IDE and Beyond
Selenium IDE and BeyondSelenium IDE and Beyond
Selenium IDE and Beyond
 
Lingle TESOL France 2012. Todays news in your classroom - Rapid Authentic Tex...
Lingle TESOL France 2012. Todays news in your classroom - Rapid Authentic Tex...Lingle TESOL France 2012. Todays news in your classroom - Rapid Authentic Tex...
Lingle TESOL France 2012. Todays news in your classroom - Rapid Authentic Tex...
 
Introducing OWASP OWTF Workshop BruCon 2012
Introducing OWASP OWTF Workshop BruCon 2012Introducing OWASP OWTF Workshop BruCon 2012
Introducing OWASP OWTF Workshop BruCon 2012
 
200,000 Lines Later: Our Journey to Manageable Puppet Code
200,000 Lines Later: Our Journey to Manageable Puppet Code200,000 Lines Later: Our Journey to Manageable Puppet Code
200,000 Lines Later: Our Journey to Manageable Puppet Code
 
Craig Sullivan - Oh Boy! These A/B tests look like total bullshit! MKTFEST 2014
Craig Sullivan - Oh Boy! These A/B tests look like total bullshit! MKTFEST 2014Craig Sullivan - Oh Boy! These A/B tests look like total bullshit! MKTFEST 2014
Craig Sullivan - Oh Boy! These A/B tests look like total bullshit! MKTFEST 2014
 
Training Webinar: Top front-end techniques for OutSystems
 Training Webinar: Top front-end techniques for OutSystems Training Webinar: Top front-end techniques for OutSystems
Training Webinar: Top front-end techniques for OutSystems
 
Top front-end techniques for OutSystems
Top front-end techniques for OutSystemsTop front-end techniques for OutSystems
Top front-end techniques for OutSystems
 

Plus de Curtis Poe

A Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassA Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::Class
Curtis Poe
 

Plus de Curtis Poe (19)

How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
life-off-earth.pptx
life-off-earth.pptxlife-off-earth.pptx
life-off-earth.pptx
 
Corinna-2023.pptx
Corinna-2023.pptxCorinna-2023.pptx
Corinna-2023.pptx
 
Corinna Status 2022.pptx
Corinna Status 2022.pptxCorinna Status 2022.pptx
Corinna Status 2022.pptx
 
Rummaging in the clOOset
Rummaging in the clOOsetRummaging in the clOOset
Rummaging in the clOOset
 
Rescuing a-legacy-codebase
Rescuing a-legacy-codebaseRescuing a-legacy-codebase
Rescuing a-legacy-codebase
 
Perl 6 For Mere Mortals
Perl 6 For Mere MortalsPerl 6 For Mere Mortals
Perl 6 For Mere Mortals
 
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, KeynoteDisappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
Disappearing Managers, YAPC::EU 2014, Bulgaria, Keynote
 
How to Fake a Database Design
How to Fake a Database DesignHow to Fake a Database Design
How to Fake a Database Design
 
Are Managers An Endangered Species?
Are Managers An Endangered Species?Are Managers An Endangered Species?
Are Managers An Endangered Species?
 
The Lies We Tell About Software Testing
The Lies We Tell About Software TestingThe Lies We Tell About Software Testing
The Lies We Tell About Software Testing
 
A Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::ClassA Whirlwind Tour of Test::Class
A Whirlwind Tour of Test::Class
 
Agile Companies Go P.O.P.
Agile Companies Go P.O.P.Agile Companies Go P.O.P.
Agile Companies Go P.O.P.
 
Econ101
Econ101Econ101
Econ101
 
Testing With Test::Class
Testing With Test::ClassTesting With Test::Class
Testing With Test::Class
 
Logic Progamming in Perl
Logic Progamming in PerlLogic Progamming in Perl
Logic Progamming in Perl
 
Inheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth VersionInheritance Versus Roles - The In-Depth Version
Inheritance Versus Roles - The In-Depth Version
 
Inheritance Versus Roles
Inheritance Versus RolesInheritance Versus Roles
Inheritance Versus Roles
 
Turbo Charged Test Suites
Turbo Charged Test SuitesTurbo Charged Test Suites
Turbo Charged Test Suites
 

Dernier

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Dernier (20)

Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 

Test::Class::Moose

Notes de l'éditeur

  1. No need to add empty control methods
  2. No need to add empty control methods
  3. No need to add empty control methods
  4. We've skipped some usual Moose boilerplate (namespace::autoclean and make_immutable)
  5. Methods beginning with test_ are test methods.Two objects to every method
  6. This works, but we constructed our object more than once. We don't want duplicated code.