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

Weitere ähnliche Inhalte

Was ist angesagt?

Java 8 selected updates
Java 8 selected updatesJava 8 selected updates
Java 8 selected updates
Vinay H G
 

Was ist angesagt? (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
 

Andere mochten auch

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
Christine Frezza
 
NET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGYNET-A-PORTER - DIGITAL MEDIA STRATEGY
NET-A-PORTER - DIGITAL MEDIA STRATEGY
Xue Kang
 
Fashion marketing basics
Fashion marketing basicsFashion marketing basics
Fashion marketing basics
ranjan trivedy
 

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

Ähnlich wie YAPC::EU::2011 - Mostly Lazy DBIx::Class Testing

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 TDD
John Cleary
 
Torquebox OSCON Java 2011
Torquebox OSCON Java 2011Torquebox OSCON Java 2011
Torquebox OSCON Java 2011
tobiascrawley
 

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

Kürzlich hochgeladen

Kürzlich hochgeladen (20)

Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
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
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 

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