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

Lessons Learned in Unit Testing

Lessons Learned in Unit Testing

Why I am in love with unit testing, and why you should be too. Delivered at WordCamp San Francisco in July 2013.

05e833e4072caac467b35d55f45b072b?s=128

Alison Barrett

July 27, 2013
Tweet

More Decks by Alison Barrett

Other Decks in Programming

Transcript

  1. LESSONS LEARNED IN UNIT TESTING Alison Barrett WordCamp San Francisco

    2013
  2. None
  3. 10 != 1

  4. Write better code.

  5. I want to inspire you.

  6. Currently: Testing by debugging

  7. We can do better.

  8. Automation saves time Debugging is easier Code is future-proof Architecture

    is modular Tests double as documentation WHY?
  9. AUTOMATION photo by pasukaru76

  10. Good, Fast, Cheap. Pick two.

  11. Writing unit tests: Good

  12. Running unit tests: Good, Fast, Cheap

  13. DEBUGGING photo by pasukaru76

  14. ......F..F...F..FFF.......................... ran 45 tests these 6 failed

  15. test_matches_browser_test MarkupA8CLinkTest 6) :: Failed asserting that 'test:/alisothegeek/?rev=3389asdf' does not

    match PCRE pattern "%(?<![\w/-])(test):\/([.\w \/-]+[\w\/])(\?rev=\d+)?(?![\w-])%". /path_to_file/MarkupA8CLinkTest.php:51 /path_to_file/MarkupA8CLinkTest.php:97 test class MarkupA8CLinkTest test function test_matches_browser_test failure failure location(s)
  16. FUTURE-PROOF photo by dunechaser

  17. Refactoring

  18. None
  19. MODULARITY photo by georgivar

  20. Unit testing not entire class testing not contents-of-a-file testing

  21. None
  22. None
  23. DOCUMENTATION photo by ercwttmn

  24. None
  25. WRAPPING UP photo by .guin

  26. Write better code.

  27. @alisothegeek alison.barre.tt QUESTIONS? All photos licensed under the Creative Commons

    Attribution license.