SlideShare ist ein Scribd-Unternehmen logo
1 von 43
Are Your Tests REALLY
     Helping?




Sunday, October 9, 2011
Motivation
           Why do we test, anyway?




Sunday, October 9, 2011
Bad Motivation




Sunday, October 9, 2011
Bad Motivation


                    • “My boss told me to”




Sunday, October 9, 2011
Bad Motivation


                    • “My boss told me to”
                    • “I’m a completist”




Sunday, October 9, 2011
Bad Motivation


                    • “My boss told me to”
                    • “I’m a completist”
                    • “I   Test Frameworks”




Sunday, October 9, 2011
Correct Motivation




Sunday, October 9, 2011
Correct Motivation


                    • Verify Correctness




Sunday, October 9, 2011
Correct Motivation


                    • Verify Correctness
                    • Gain Confidence




Sunday, October 9, 2011
Correct Motivation


                    • Verify Correctness
                    • Gain Confidence
                    • Communication




Sunday, October 9, 2011
Test Types
                          Vocabulary Break!




Sunday, October 9, 2011
Functional Tests


                          Does the overall
                          product satisfy the
                          the requirements?




Sunday, October 9, 2011
Integration Tests


                          Do the pieces t
                          together?




Sunday, October 9, 2011
Unit Tests


                          Is the logic correct in
                          that function?




Sunday, October 9, 2011
Functional
             Understand the product.




Sunday, October 9, 2011
The Tools




Sunday, October 9, 2011
The Tools


                    • BeHat (Cucumber)




Sunday, October 9, 2011
The Tools


                    • BeHat (Cucumber)
                    • PHPSpec




Sunday, October 9, 2011
The Tools


                    • BeHat (Cucumber)
                    • PHPSpec
                    • Keyboard, Mouse, and You




Sunday, October 9, 2011
When Do They Work?

                    • During prototyping
                    • Focused on the product requirements
                    • Refactoring
                    • Regression of key features
                    • Better for smaller teams


Sunday, October 9, 2011
...Stop Helping?


                    • Focused on the implementation
                    • Rapidly changing functionality
                    • Large organizations




Sunday, October 9, 2011
Unit Tests
              Simple and to the point.




Sunday, October 9, 2011
Verify Correctness


                    • Line coverage
                    • Branch coverage
                    • Icky Bits-o-Logic




Sunday, October 9, 2011
Gain Condence

                    • Individual functions
                    • Variety of parameters
                    • Works for expected interactions with
                      collaborators




Sunday, October 9, 2011
Communication

                    • Show how to use the function
                    • Show expected interactions with other
                      collaborators
                    • Increase discoverability of possible
                      reuse



Sunday, October 9, 2011
PHPUnit Standard



Sunday, October 9, 2011
Naming

                    • Pick a directory just for tests
                    • Pick a test file name suffix, ie. Test.php
                    • Match the name of the test file to the
                      name of the le being tested




Sunday, October 9, 2011
Classes

                    • One class per test file
                    • Name should match the file name
                    • Extend only tested TestCase classes
                    • No interfaces or abstract classes



Sunday, October 9, 2011
Functions
                    • No private functions
                    • Protected methods are reserved for
                      overriding parent methods
                    • Only provider and test methods are
                      allowed
                    • Make sure your provider and test
                      methods are public

Sunday, October 9, 2011
Control Structures



                    • There should be NO control structures




Sunday, October 9, 2011
PHPUnit Code Standard
                •         AllowedFunctionOverride
                •         ClassName
                •         ExtraneousClass
                •         FilenameSuffix
                •         NoInterfaces
                •         NoPrivateMethods
                •         ProvenTestCase
                •         TestOrProviderFunctionsOnly
                •         TestOrProviderIsPublic
                •         UnusedProvider

Sunday, October 9, 2011
PHP_CodeSniffer


                • CyclomaticComplexity (maximum of 1)
                • NestingLevel (maximum of 0)
                • UnnecessaryOverride




Sunday, October 9, 2011
PHP_CodeSniffer


                          Standard Available at:
                          http://github.com/elblinkin/
                          PHPUnit-CodeSniffer




Sunday, October 9, 2011
Save Time


                    • Test code MTTI of 0
                    • Reduce the connascence
                    • Scales with growing development team




Sunday, October 9, 2011
More...
                    • Ensure only one class is under test
                    • Avoid accessing globals
                          • Environment variables

                          • Configuration from disk

                    • Prevent interactions with external
                      resources
                    • Code Standard for Testability

Sunday, October 9, 2011
Integration
                          For everything in-between.




Sunday, October 9, 2011
You’re Paranoid

                    • Experimenting with third-party code or
                      service
                    • You do not trust that your collaborators
                      work as specied




Sunday, October 9, 2011
Save Time

                    • Save Time
                          • Discover integration issues early

                    • Waste of Time
                          • Time spent testing third-party code




Sunday, October 9, 2011
Warning


                    • Use them for experimentation
                    • Consider an alert instead
                    • Do not inflict them on others




Sunday, October 9, 2011
Good or Bad?


                    • Mock         • Code Coverage
                    • Manual       • Automated
                    • Copy/Paste   • Reuse




Sunday, October 9, 2011
Review
                    • Functional Tests
                          • prototyping, early stage, small team

                    • Unit Tests
                          • can be too much for early stage

                          • scale with a growing team size and code base

                    • Integration Tests
                          • only because you are paranoid


Sunday, October 9, 2011
Other Test Types

                    • Performance Testing
                    • Load Testing
                    • Security Testing
                    • Monitoring
                    • Logging


Sunday, October 9, 2011
• Who Am I?
                          @elblinkin : Etsy, Inc.

                • Want More?
                          http://codeascraft.etsy.com

                          http://github.com/etsy

                          http://elblinkin.info




Sunday, October 9, 2011

Weitere ähnliche Inhalte

Ähnlich wie Are Your Tests Really Helping You?

Test Driven Sysadmin
Test Driven SysadminTest Driven Sysadmin
Test Driven Sysadmin
johanku
 
Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)
zeeg
 
PHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An IntroductionPHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An Introduction
alexmace
 
2010.10.30 steven sustaining tdd agile tour shenzhen
2010.10.30 steven sustaining tdd   agile tour shenzhen2010.10.30 steven sustaining tdd   agile tour shenzhen
2010.10.30 steven sustaining tdd agile tour shenzhen
Odd-e
 
Monitoring is easy, why are we so bad at it presentation
Monitoring is easy, why are we so bad at it  presentationMonitoring is easy, why are we so bad at it  presentation
Monitoring is easy, why are we so bad at it presentation
Theo Schlossnagle
 
Practical Cloud Security
Practical Cloud SecurityPractical Cloud Security
Practical Cloud Security
Jason Chan
 
Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011)
Leonardo Borges
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
Caridy Patino
 
Is this how you hate unit testing?
Is this how you hate unit testing?Is this how you hate unit testing?
Is this how you hate unit testing?
Steven Mak
 

Ähnlich wie Are Your Tests Really Helping You? (20)

High quality iOS development
High quality iOS developmentHigh quality iOS development
High quality iOS development
 
Test Driven Sysadmin
Test Driven SysadminTest Driven Sysadmin
Test Driven Sysadmin
 
Atlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide DeckAtlassian RoadTrip 2011 Slide Deck
Atlassian RoadTrip 2011 Slide Deck
 
Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)Continuous Deployment at Disqus (Pylons Minicon)
Continuous Deployment at Disqus (Pylons Minicon)
 
PHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An IntroductionPHPUnit & Continuous Integration: An Introduction
PHPUnit & Continuous Integration: An Introduction
 
Bonfire... How'd You Do That?! - AtlasCamp 2011
Bonfire... How'd You Do That?! - AtlasCamp 2011Bonfire... How'd You Do That?! - AtlasCamp 2011
Bonfire... How'd You Do That?! - AtlasCamp 2011
 
Fred Spencer: Designing a Great UI
Fred Spencer: Designing a Great UIFred Spencer: Designing a Great UI
Fred Spencer: Designing a Great UI
 
Infusion for the birds
Infusion for the birdsInfusion for the birds
Infusion for the birds
 
Developers! Y U No Open Source Ur Code?
Developers! Y U No Open Source Ur Code?Developers! Y U No Open Source Ur Code?
Developers! Y U No Open Source Ur Code?
 
2010.10.30 steven sustaining tdd agile tour shenzhen
2010.10.30 steven sustaining tdd   agile tour shenzhen2010.10.30 steven sustaining tdd   agile tour shenzhen
2010.10.30 steven sustaining tdd agile tour shenzhen
 
Monitoring is easy, why are we so bad at it presentation
Monitoring is easy, why are we so bad at it  presentationMonitoring is easy, why are we so bad at it  presentation
Monitoring is easy, why are we so bad at it presentation
 
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
Integrating ECM (WebCenter Content) with your Enterprise! 5 Tips to Try, 5 Tr...
 
Practical Cloud Security
Practical Cloud SecurityPractical Cloud Security
Practical Cloud Security
 
Extending rails
Extending railsExtending rails
Extending rails
 
Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011)
 
Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
Puppet camp europe 2011 hackability
Puppet camp europe 2011   hackabilityPuppet camp europe 2011   hackability
Puppet camp europe 2011 hackability
 
Is this how you hate unit testing?
Is this how you hate unit testing?Is this how you hate unit testing?
Is this how you hate unit testing?
 
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan GallimoreJava EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
Java EE | Apache TomEE - Java EE Web Profile on Tomcat | Jonathan Gallimore
 

Mehr von LB Denker

Testing and DevOps Culture: Lessons Learned
Testing and DevOps Culture: Lessons LearnedTesting and DevOps Culture: Lessons Learned
Testing and DevOps Culture: Lessons Learned
LB Denker
 
Php com con-2011
Php com con-2011Php com con-2011
Php com con-2011
LB Denker
 

Mehr von LB Denker (7)

Testing and DevOps Culture: Lessons Learned
Testing and DevOps Culture: Lessons LearnedTesting and DevOps Culture: Lessons Learned
Testing and DevOps Culture: Lessons Learned
 
Php|tek '12 It's More Than Just Style
Php|tek '12  It's More Than Just StylePhp|tek '12  It's More Than Just Style
Php|tek '12 It's More Than Just Style
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
 
phpDay 2012: Scaling Communication via Continuous Integration
phpDay 2012: Scaling Communication via Continuous IntegrationphpDay 2012: Scaling Communication via Continuous Integration
phpDay 2012: Scaling Communication via Continuous Integration
 
QC Merge 2012: Growing community
QC Merge 2012: Growing communityQC Merge 2012: Growing community
QC Merge 2012: Growing community
 
PHP UK Conference 2012: Scaling Communication via Continuous Integration
PHP UK Conference 2012: Scaling Communication via Continuous IntegrationPHP UK Conference 2012: Scaling Communication via Continuous Integration
PHP UK Conference 2012: Scaling Communication via Continuous Integration
 
Php com con-2011
Php com con-2011Php com con-2011
Php com con-2011
 

KĂźrzlich hochgeladen

CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

KĂźrzlich hochgeladen (20)

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...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
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
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
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...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
[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
 
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...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 

Are Your Tests Really Helping You?

  • 1. Are Your Tests REALLY Helping? Sunday, October 9, 2011
  • 2. Motivation Why do we test, anyway? Sunday, October 9, 2011
  • 4. Bad Motivation • “My boss told me to” Sunday, October 9, 2011
  • 5. Bad Motivation • “My boss told me to” • “I’m a completist” Sunday, October 9, 2011
  • 6. Bad Motivation • “My boss told me to” • “I’m a completist” • “I Test Frameworks” Sunday, October 9, 2011
  • 8. Correct Motivation • Verify Correctness Sunday, October 9, 2011
  • 9. Correct Motivation • Verify Correctness • Gain Condence Sunday, October 9, 2011
  • 10. Correct Motivation • Verify Correctness • Gain Condence • Communication Sunday, October 9, 2011
  • 11. Test Types Vocabulary Break! Sunday, October 9, 2011
  • 12. Functional Tests Does the overall product satisfy the the requirements? Sunday, October 9, 2011
  • 13. Integration Tests Do the pieces t together? Sunday, October 9, 2011
  • 14. Unit Tests Is the logic correct in that function? Sunday, October 9, 2011
  • 15. Functional Understand the product. Sunday, October 9, 2011
  • 17. The Tools • BeHat (Cucumber) Sunday, October 9, 2011
  • 18. The Tools • BeHat (Cucumber) • PHPSpec Sunday, October 9, 2011
  • 19. The Tools • BeHat (Cucumber) • PHPSpec • Keyboard, Mouse, and You Sunday, October 9, 2011
  • 20. When Do They Work? • During prototyping • Focused on the product requirements • Refactoring • Regression of key features • Better for smaller teams Sunday, October 9, 2011
  • 21. ...Stop Helping? • Focused on the implementation • Rapidly changing functionality • Large organizations Sunday, October 9, 2011
  • 22. Unit Tests Simple and to the point. Sunday, October 9, 2011
  • 23. Verify Correctness • Line coverage • Branch coverage • Icky Bits-o-Logic Sunday, October 9, 2011
  • 24. Gain Condence • Individual functions • Variety of parameters • Works for expected interactions with collaborators Sunday, October 9, 2011
  • 25. Communication • Show how to use the function • Show expected interactions with other collaborators • Increase discoverability of possible reuse Sunday, October 9, 2011
  • 27. Naming • Pick a directory just for tests • Pick a test le name sufx, ie. Test.php • Match the name of the test le to the name of the le being tested Sunday, October 9, 2011
  • 28. Classes • One class per test le • Name should match the le name • Extend only tested TestCase classes • No interfaces or abstract classes Sunday, October 9, 2011
  • 29. Functions • No private functions • Protected methods are reserved for overriding parent methods • Only provider and test methods are allowed • Make sure your provider and test methods are public Sunday, October 9, 2011
  • 30. Control Structures • There should be NO control structures Sunday, October 9, 2011
  • 31. PHPUnit Code Standard • AllowedFunctionOverride • ClassName • ExtraneousClass • FilenameSufx • NoInterfaces • NoPrivateMethods • ProvenTestCase • TestOrProviderFunctionsOnly • TestOrProviderIsPublic • UnusedProvider Sunday, October 9, 2011
  • 32. PHP_CodeSniffer • CyclomaticComplexity (maximum of 1) • NestingLevel (maximum of 0) • UnnecessaryOverride Sunday, October 9, 2011
  • 33. PHP_CodeSniffer Standard Available at: http://github.com/elblinkin/ PHPUnit-CodeSniffer Sunday, October 9, 2011
  • 34. Save Time • Test code MTTI of 0 • Reduce the connascence • Scales with growing development team Sunday, October 9, 2011
  • 35. More... • Ensure only one class is under test • Avoid accessing globals • Environment variables • Conguration from disk • Prevent interactions with external resources • Code Standard for Testability Sunday, October 9, 2011
  • 36. Integration For everything in-between. Sunday, October 9, 2011
  • 37. You’re Paranoid • Experimenting with third-party code or service • You do not trust that your collaborators work as specied Sunday, October 9, 2011
  • 38. Save Time • Save Time • Discover integration issues early • Waste of Time • Time spent testing third-party code Sunday, October 9, 2011
  • 39. Warning • Use them for experimentation • Consider an alert instead • Do not inflict them on others Sunday, October 9, 2011
  • 40. Good or Bad? • Mock • Code Coverage • Manual • Automated • Copy/Paste • Reuse Sunday, October 9, 2011
  • 41. Review • Functional Tests • prototyping, early stage, small team • Unit Tests • can be too much for early stage • scale with a growing team size and code base • Integration Tests • only because you are paranoid Sunday, October 9, 2011
  • 42. Other Test Types • Performance Testing • Load Testing • Security Testing • Monitoring • Logging Sunday, October 9, 2011
  • 43. • Who Am I? @elblinkin : Etsy, Inc. • Want More? http://codeascraft.etsy.com http://github.com/etsy http://elblinkin.info Sunday, October 9, 2011