SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
Introduction                      Test::DBIx::Class::Schema       Future        Finally




                           Mostly Lazy DBIx::Class Testing

                                                Chisel Wright

                                                   Net-A-Porter


                                                       2011




Mostly Lazy DBIx::Class Testing                                            Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




In A Nutshell




                            DBIx::Class schema sanity checking tests




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Why?




                          Ongoing Quest To Be As LAZY As Possible




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy



       # are specific columns defined?

       my $thingy = $model->resultset(’BigBagOfFail’);

       my @columns = qw/id name department/);

       can_ok($thingy, @columns);




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy


       foreach my $column (@columns) {
         try {
           $thingy->$column();
           ok("called $column()");
         }
         catch($e) {
           diag $e;
           fail("$column() failed");
         }
       }



Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy




       What about . . . ?
               relationships
               custom methods




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Non-Lazy




               Decide to test something new?
               How many .t files do you need to edit?
               More than zero?
               Too much work!!




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema      Future        Finally




Getting Lazy




                                     Test::DBIx::Class::Schema




Mostly Lazy DBIx::Class Testing                                           Net-A-Porter
Introduction                      Test::DBIx::Class::Schema     Future        Finally




Test::DBIx::Class::Schema




                                       My Attempt At Laziness




Mostly Lazy DBIx::Class Testing                                          Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future         Finally




An example (setup)



       my $schematest              = Test::DBIx::Class::Schema->new({
         # required
         dsn        =>             ’dbi:Pg:dbname=mydb’,
         namespace =>              ’MyDB::Schema’,
         moniker    =>             ’SomeTable’,
         # optional
         username =>               ’some_user’,
         password =>               ’opensesame’,
       });




Mostly Lazy DBIx::Class Testing                                         Net-A-Porter
Introduction                       Test::DBIx::Class::Schema   Future        Finally




An example (config)


       # tell it what to test
       $schematest->methods({
         columns    => [ qw( id name ) ],

           relations              => [ qw( foo ) ],

           custom                 => [ qw( some_method ) ],

         resultsets => [ qw( ) ],
       });



Mostly Lazy DBIx::Class Testing                                         Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




An example (running)




       $schematest->run_tests();




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




You get. . .




               can ok( @columns )
               can ok( @relations )
               can ok( @customs ) # row subs
               can ok( @resultsets ) # rs subs




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




You also get. . .



               $thing->$column called ok
               $thing->$relation called ok
               test that $column exists in the database
               ensure related-source exists
               test self.* and foreign.* columns for relationships
               test proxied relationships
               PASS/FAIL for relationship validity




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




You don’t get




                             Functional Testing



Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Benefits




               only maintaining a list (or three)
               lots of sanity checking
               find out if someone deletes columns from the database
               upgrading ’TDCS’ improves *.t files for free




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Recommendations




               Test one table/class per file
               Use Test::Aggregate
               Factor out ->new call for $schema




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema     Future        Finally




In The Real World




               on the CPAN since 2008
               used in production code since 2009
               recent burst of improvements
                      never used to test empty tables - OOPS!
                      used to be quite basic




Mostly Lazy DBIx::Class Testing                                          Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




Did It Work?




                                                  YES!
                                                   IMNSHO




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                      Test::DBIx::Class::Schema   Future        Finally




What Next?




       Wishlist
               relationship reciprocity
               relationships that are coderefs
               db columns that aren’t in the schema?
               tie-in with DBIx::Class::Schema::Loader




Mostly Lazy DBIx::Class Testing                                        Net-A-Porter
Introduction                       Test::DBIx::Class::Schema   Future        Finally




End Credits



                                   QUESTIONS?
       Me:
               chisel.wright@net-a-porter.com
               CPANID: CHISEL
               github:            github.com/chiselwright
       Module:
               metacpan.org/release/Test-DBIx-Class-Schema
               github.com/chiselwright/test-dbix-class-schema


Mostly Lazy DBIx::Class Testing                                         Net-A-Porter

Más contenido relacionado

La actualidad más candente

Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updatesVinay H G
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapDave Orme
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesHitesh-Java
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java LanguagePawanMM
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaDerek Chen-Becker
 
Exception Handling - Continued
Exception Handling - Continued Exception Handling - Continued
Exception Handling - Continued Hitesh-Java
 
Scala in practice
Scala in practiceScala in practice
Scala in practiceTomer Gabel
 
Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3PawanMM
 
Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Hitesh-Java
 
Session 01 - Introduction to Java
Session 01 - Introduction to JavaSession 01 - Introduction to Java
Session 01 - Introduction to JavaPawanMM
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesSession 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesPawanMM
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java BasicsFayis-QA
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part oneBingfeng Zhao
 
Rapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsRapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsSimobo
 

La actualidad más candente (17)

Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updates
 
Refactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 RecapRefactoring to Scala DSLs and LiftOff 2009 Recap
Refactoring to Scala DSLs and LiftOff 2009 Recap
 
OOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and InterfacesOOP with Java - Abstract Classes and Interfaces
OOP with Java - Abstract Classes and Interfaces
 
Oop lecture3
Oop lecture3Oop lecture3
Oop lecture3
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 
Java OOPs
Java OOPs Java OOPs
Java OOPs
 
A Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to ScalaA Brief, but Dense, Intro to Scala
A Brief, but Dense, Intro to Scala
 
Exception Handling - Continued
Exception Handling - Continued Exception Handling - Continued
Exception Handling - Continued
 
Scala in practice
Scala in practiceScala in practice
Scala in practice
 
Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3Session 09 - OOP with Java - Part 3
Session 09 - OOP with Java - Part 3
 
Review Session and Attending Java Interviews
Review Session and Attending Java Interviews Review Session and Attending Java Interviews
Review Session and Attending Java Interviews
 
Session 01 - Introduction to Java
Session 01 - Introduction to JavaSession 01 - Introduction to Java
Session 01 - Introduction to Java
 
Session 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and InterfacesSession 10 - OOP with Java - Abstract Classes and Interfaces
Session 10 - OOP with Java - Abstract Classes and Interfaces
 
Core Java Basics
Core Java BasicsCore Java Basics
Core Java Basics
 
From code to pattern, part one
From code to pattern, part oneFrom code to pattern, part one
From code to pattern, part one
 
Rapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsRapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on Rails
 
Viva file
Viva fileViva file
Viva file
 

Destacado

Frezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelryFrezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelryChristine Frezza
 
Fashion Marketing Week 2
Fashion Marketing Week 2Fashion Marketing Week 2
Fashion Marketing Week 2janemonkey
 
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16Balistik Art
 
Fashion Brand Managment - Marchesa
Fashion Brand Managment - MarchesaFashion Brand Managment - Marchesa
Fashion Brand Managment - MarchesaShirley, Yan Yu Tin
 
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...Convertize
 
Fashion Marketing Ch 2
Fashion Marketing Ch 2Fashion Marketing Ch 2
Fashion Marketing Ch 2Msotter
 
hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015Daisuke Ishii
 
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...BGMEA University of Fashion & Technology
 
NET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGYNET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGYXue Kang
 
Fashion marketing basics
Fashion marketing basicsFashion marketing basics
Fashion marketing basicsranjan trivedy
 
Versace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentationVersace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentationHimel Hawlader
 
Building elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-PorterBuilding elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-PorterRobin Glen
 
Assortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartneyAssortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartneyvibber
 
How to Design Compelling Content Experiences
How to Design Compelling Content ExperiencesHow to Design Compelling Content Experiences
How to Design Compelling Content ExperiencesUberflip
 

Destacado (20)

Frezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelryFrezza_Christine_Macy’s_classification_of_costume_jewelry
Frezza_Christine_Macy’s_classification_of_costume_jewelry
 
Phoenix Fashion Week 2016 Digital Program
Phoenix Fashion Week 2016 Digital ProgramPhoenix Fashion Week 2016 Digital Program
Phoenix Fashion Week 2016 Digital Program
 
Fashion Marketing Week 2
Fashion Marketing Week 2Fashion Marketing Week 2
Fashion Marketing Week 2
 
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
BLSTK Replay n°152 - la revue luxe et digitale 25.02 au 02.03.16
 
Fashion Brand Managment - Marchesa
Fashion Brand Managment - MarchesaFashion Brand Managment - Marchesa
Fashion Brand Managment - Marchesa
 
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
[NET-A-PORTER] 9 Persuasive Principle Used by NET-A-PORTER to Boost their Con...
 
Fashion Marketing Ch 2
Fashion Marketing Ch 2Fashion Marketing Ch 2
Fashion Marketing Ch 2
 
hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015hallu - Japanese Fashion Brand Pitch May 2015
hallu - Japanese Fashion Brand Pitch May 2015
 
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
Fashion marketing : Marketing statement, object,Marketing plan, Marketing str...
 
Fashion Marketing (Branding)
Fashion Marketing (Branding)Fashion Marketing (Branding)
Fashion Marketing (Branding)
 
Vietnamese fashion brand recognition survey
Vietnamese fashion brand recognition surveyVietnamese fashion brand recognition survey
Vietnamese fashion brand recognition survey
 
NET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGYNET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGY
 
Fashion market studies_thailand_22042015
Fashion market studies_thailand_22042015Fashion market studies_thailand_22042015
Fashion market studies_thailand_22042015
 
Fashion marketing basics
Fashion marketing basicsFashion marketing basics
Fashion marketing basics
 
Versace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentationVersace fashion Brand Analyses presentation
Versace fashion Brand Analyses presentation
 
Chapter 1 Fashion Marketing
Chapter   1 Fashion MarketingChapter   1 Fashion Marketing
Chapter 1 Fashion Marketing
 
Building elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-PorterBuilding elements and experiences at Net-A-Porter
Building elements and experiences at Net-A-Porter
 
Assortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartneyAssortment ss 2015 Stella McCartney
Assortment ss 2015 Stella McCartney
 
How to Design Compelling Content Experiences
How to Design Compelling Content ExperiencesHow to Design Compelling Content Experiences
How to Design Compelling Content Experiences
 
Net-a-Porter Social Media
Net-a-Porter Social MediaNet-a-Porter Social Media
Net-a-Porter Social Media
 

Similar a YAPC::EU::2011 - Mostly Lazy DBIx::Class Testing

Test::Kantan - Perl and Testing
Test::Kantan - Perl and TestingTest::Kantan - Perl and Testing
Test::Kantan - Perl and TestingTokuhiro Matsuno
 
WebNano - Ideas for Web Frameworks
WebNano - Ideas for Web FrameworksWebNano - Ideas for Web Frameworks
WebNano - Ideas for Web Frameworksguestf89f9cb
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesiMasters
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overviewjonkinney
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)Felix Geisendörfer
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD WorkshopWolfram Arnold
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»e-Legion
 
Making friends with TDD
Making friends with TDDMaking friends with TDD
Making friends with TDDJohn Cleary
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Workhorse Computing
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011tobiascrawley
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyNick Sieger
 
Liquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseLiquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseBlaine Carter
 
JRuby e DSL
JRuby e DSLJRuby e DSL
JRuby e DSLjodosha
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the BasicsMichael Koby
 
First adoption hackathon at BGJUG
First adoption hackathon at BGJUGFirst adoption hackathon at BGJUG
First adoption hackathon at BGJUGIvan Ivanov
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for RubyHiroshi SHIBATA
 

Similar a YAPC::EU::2011 - Mostly Lazy DBIx::Class Testing (20)

Test::Kantan - Perl and Testing
Test::Kantan - Perl and TestingTest::Kantan - Perl and Testing
Test::Kantan - Perl and Testing
 
WebNano - Ideas for Web Frameworks
WebNano - Ideas for Web FrameworksWebNano - Ideas for Web Frameworks
WebNano - Ideas for Web Frameworks
 
Sanity on Rails
Sanity on RailsSanity on Rails
Sanity on Rails
 
Modernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul JonesModernizing Legacy Applications in PHP, por Paul Jones
Modernizing Legacy Applications in PHP, por Paul Jones
 
Scalax
ScalaxScalax
Scalax
 
Testing con spock
Testing con spockTesting con spock
Testing con spock
 
Ruby On Rails Overview
Ruby On Rails OverviewRuby On Rails Overview
Ruby On Rails Overview
 
How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)How to Test Asynchronous Code (v2)
How to Test Asynchronous Code (v2)
 
2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop2011-02-03 LA RubyConf Rails3 TDD Workshop
2011-02-03 LA RubyConf Rails3 TDD Workshop
 
Intro to J Ruby
Intro to J RubyIntro to J Ruby
Intro to J Ruby
 
Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»Rafael Bagmanov «Scala in a wild enterprise»
Rafael Bagmanov «Scala in a wild enterprise»
 
Making friends with TDD
Making friends with TDDMaking friends with TDD
Making friends with TDD
 
Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.Object Trampoline: Why having not the object you want is what you need.
Object Trampoline: Why having not the object you want is what you need.
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
 
Connecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRubyConnecting the Worlds of Java and Ruby with JRuby
Connecting the Worlds of Java and Ruby with JRuby
 
Liquibase - Open Source version control for your database
Liquibase - Open Source version control for your databaseLiquibase - Open Source version control for your database
Liquibase - Open Source version control for your database
 
JRuby e DSL
JRuby e DSLJRuby e DSL
JRuby e DSL
 
Ruby: Beyond the Basics
Ruby: Beyond the BasicsRuby: Beyond the Basics
Ruby: Beyond the Basics
 
First adoption hackathon at BGJUG
First adoption hackathon at BGJUGFirst adoption hackathon at BGJUG
First adoption hackathon at BGJUG
 
The details of CI/CD environment for Ruby
The details of CI/CD environment for RubyThe details of CI/CD environment for Ruby
The details of CI/CD environment for Ruby
 

Último

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 

Último (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 

YAPC::EU::2011 - Mostly Lazy DBIx::Class Testing

  • 1. Introduction Test::DBIx::Class::Schema Future Finally Mostly Lazy DBIx::Class Testing Chisel Wright Net-A-Porter 2011 Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 2. Introduction Test::DBIx::Class::Schema Future Finally In A Nutshell DBIx::Class schema sanity checking tests Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 3. Introduction Test::DBIx::Class::Schema Future Finally Why? Ongoing Quest To Be As LAZY As Possible Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 4. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy # are specific columns defined? my $thingy = $model->resultset(’BigBagOfFail’); my @columns = qw/id name department/); can_ok($thingy, @columns); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 5. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy foreach my $column (@columns) { try { $thingy->$column(); ok("called $column()"); } catch($e) { diag $e; fail("$column() failed"); } } Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 6. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy What about . . . ? relationships custom methods Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 7. Introduction Test::DBIx::Class::Schema Future Finally Non-Lazy Decide to test something new? How many .t files do you need to edit? More than zero? Too much work!! Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 8. Introduction Test::DBIx::Class::Schema Future Finally Getting Lazy Test::DBIx::Class::Schema Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 9. Introduction Test::DBIx::Class::Schema Future Finally Test::DBIx::Class::Schema My Attempt At Laziness Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 10. Introduction Test::DBIx::Class::Schema Future Finally An example (setup) my $schematest = Test::DBIx::Class::Schema->new({ # required dsn => ’dbi:Pg:dbname=mydb’, namespace => ’MyDB::Schema’, moniker => ’SomeTable’, # optional username => ’some_user’, password => ’opensesame’, }); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 11. Introduction Test::DBIx::Class::Schema Future Finally An example (config) # tell it what to test $schematest->methods({ columns => [ qw( id name ) ], relations => [ qw( foo ) ], custom => [ qw( some_method ) ], resultsets => [ qw( ) ], }); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 12. Introduction Test::DBIx::Class::Schema Future Finally An example (running) $schematest->run_tests(); Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 13. Introduction Test::DBIx::Class::Schema Future Finally You get. . . can ok( @columns ) can ok( @relations ) can ok( @customs ) # row subs can ok( @resultsets ) # rs subs Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 14. Introduction Test::DBIx::Class::Schema Future Finally You also get. . . $thing->$column called ok $thing->$relation called ok test that $column exists in the database ensure related-source exists test self.* and foreign.* columns for relationships test proxied relationships PASS/FAIL for relationship validity Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 15. Introduction Test::DBIx::Class::Schema Future Finally You don’t get Functional Testing Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 16. Introduction Test::DBIx::Class::Schema Future Finally Benefits only maintaining a list (or three) lots of sanity checking find out if someone deletes columns from the database upgrading ’TDCS’ improves *.t files for free Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 17. Introduction Test::DBIx::Class::Schema Future Finally Recommendations Test one table/class per file Use Test::Aggregate Factor out ->new call for $schema Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 18. Introduction Test::DBIx::Class::Schema Future Finally In The Real World on the CPAN since 2008 used in production code since 2009 recent burst of improvements never used to test empty tables - OOPS! used to be quite basic Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 19. Introduction Test::DBIx::Class::Schema Future Finally Did It Work? YES! IMNSHO Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 20. Introduction Test::DBIx::Class::Schema Future Finally What Next? Wishlist relationship reciprocity relationships that are coderefs db columns that aren’t in the schema? tie-in with DBIx::Class::Schema::Loader Mostly Lazy DBIx::Class Testing Net-A-Porter
  • 21. Introduction Test::DBIx::Class::Schema Future Finally End Credits QUESTIONS? Me: chisel.wright@net-a-porter.com CPANID: CHISEL github: github.com/chiselwright Module: metacpan.org/release/Test-DBIx-Class-Schema github.com/chiselwright/test-dbix-class-schema Mostly Lazy DBIx::Class Testing Net-A-Porter