Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Why You Can't Test

Why You Can't Test

Slides for a talk I gave at CakeFest 2014 about obstacles developers face when they decide to start writing automated tests for their code.

Chris Hartjes

August 24, 2014
Tweet

More Decks by Chris Hartjes

Other Decks in Technology

Transcript

  1. Configuration Use Composer (http://getcomposer.org) to isolate tools to your project

    Modify your project to fit the defaults of tools whenever possible Avoid fighting with tools but also resist urge to write your own
  2. Configuration Avoid “my project is SOOOOO unique” mentality Makes it

    increasingly difficult to integrate other projects Convention over configuration matters
  3. Education Impossible to learn how to write tests in isolation

    Mentorships are awesome! (http://phpmentoring.org) Talking about mentoring is awesome (#phpmentoring on Freenode)
  4. Education Mentoring is a great way to make connections My

    own apprentices have gone on to success Easy way to give back to the community
  5. Coupling Containers are simply a way to store something for

    later retrieval Think “define stuff in my bootstrap sequence”
  6. Coupling Dependency Injection Containers and Service Locators are simply globally-available

    ways to retrieve stuff Be sure to not make you code dependant on the container / locator!
  7. Dependencies You never know it until you try to create

    mocks for them Every dependency you add needs to be justified
  8. Dependencies “Mocking” is the creation of copies of dependencies the

    code you are testing has You create those copies in a specific state Easiest way to see if your code is testable — can you easily inject dependencies in?
  9. Misconceptions Getting paid not to write code, but to solve

    problems Many people discount the costs of fixing bugs Many people discount the costs of missed opportunities bugs create
  10. Misconceptions TDD is about shifting bug-fixing to a cheaper part

    of the process TDD is a design pattern! 20% to 40% more time for 40% to 90% fewer bugs
  11. Misconceptions Bugs found in development cost $X Bugs found by

    QA cost $2X Bugs found in production cost $10X
  12. Environments Composer can play double duty Vagrant / other virtual

    machines are key Repeatable automated processes are key
  13. Environments Composer lets you lock down the environment Easy to

    specify versions of all libraries Reduce likelihood of “works on my machine”
  14. Environments People make mistakes all the tie Computers make mistakes

    you tell them to Examine procedures carefully to find automation opportunities
  15. Motivation Good test suites make bug fixes easy Good test

    suites make it easier to integrate new things
  16. Motivation Good test suites mean more time worrying about big

    problems Good test suites mean less time worrying about regressions
  17. Feed My Ego [email protected] @grmpyprogrammer ASK ME ANYTHING - I

    READ ALL EMAIL AND TWEETS https://joind.in/11602