SlideShare uma empresa Scribd logo
1 de 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 fit
                          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 Confidence

                    • 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 file 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 specified




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

Mais conteúdo relacionado

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

+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@
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
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...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
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
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
+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...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
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
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 

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 Confidence Sunday, October 9, 2011
  • 10. Correct Motivation • Verify Correctness • Gain Confidence • 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 fit 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 Confidence • 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 file name suffix, ie. Test.php • Match the name of the test file to the name of the file being tested Sunday, October 9, 2011
  • 28. 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
  • 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 • FilenameSuffix • 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 • Configuration 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 specified 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