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
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 inďŹict 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