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

I Walk In The Shadow Of Valley Of Tests

I Walk In The Shadow Of Valley Of Tests

Most if not all people in the software development world are telling you that you should write tests for your code. The amount of articles, blog posts, books, and white papers is overwhelming, you start reading them, you feel you are ready, and then you take a look at your code. Chances are you will get disheartened, by the sheer amount of it, by how it might seem hard, by terminology and approaches, by flavors of testing, by the investment of time required, by plain "OMG, I need to touch that code piece, things might break", or by tight deadlines of small projects. We will be looking at ways to start introducing the tests into your code base, to try and cross the uncanny valley of tests, which claimed lives of many code hours.

Vranac Srdjan

November 22, 2014
Tweet

More Decks by Vranac Srdjan

Other Decks in Programming

Transcript

  1. I WALK IN THE
    SHADOW OF VALLEY
    OF TESTS
    Code4Hire, 2014, PHP T-Day 1

    View full-size slide

  2. business owner, developer, consultant, mercenary, writing
    terrible code that performs exceptionally, wrangling
    elePHPants and Pythons, obsessed with process automation,
    interested in continuous integration and delivery, clean code,
    testing, best practices and distributed systems
    Code4Hire, 2014, PHP T-Day 2

    View full-size slide

  3. Code4Hire, 2014, PHP T-Day 3

    View full-size slide

  4. Code4Hire, 2014, PHP T-Day 4

    View full-size slide

  5. Code4Hire, 2014, PHP T-Day 5

    View full-size slide

  6. Code4Hire, 2014, PHP T-Day 6

    View full-size slide

  7. Code4Hire, 2014, PHP T-Day 7

    View full-size slide

  8. Code4Hire, 2014, PHP T-Day 8

    View full-size slide

  9. Code4Hire, 2014, PHP T-Day 9

    View full-size slide

  10. Code4Hire, 2014, PHP T-Day 10

    View full-size slide

  11. SSSSSOURCE SSSSSNAKE
    Code4Hire, 2014, PHP T-Day 11

    View full-size slide

  12. Testing Calisthenics
    First learn stand, then learn fly.
    Nature rule, Daniel-san, not mine.
    — Miyagi
    Code4Hire, 2014, PHP T-Day 12

    View full-size slide

  13. Testing Calisthenics
    cyber-dojo.org
    checkio.org
    Code4Hire, 2014, PHP T-Day 13

    View full-size slide

  14. Where to start?
    Code4Hire, 2014, PHP T-Day 14

    View full-size slide

  15. Rule of thumb
    Code4Hire, 2014, PHP T-Day 15

    View full-size slide

  16. Refactor, Test, Rinse, Repeat
    Code4Hire, 2014, PHP T-Day 16

    View full-size slide

  17. Mocks Vs Stubs
    Code4Hire, 2014, PHP T-Day 17

    View full-size slide

  18. Mocks Vs Stubs
    • Dummy
    • Fake
    • Stub
    • Mock
    Code4Hire, 2014, PHP T-Day 18

    View full-size slide

  19. Mocks Vs Stubs
    • Dummy
    • Fake
    • Stub
    • Mock
    Code4Hire, 2014, PHP T-Day 19

    View full-size slide

  20. Mocks Vs Stubs
    Code4Hire, 2014, PHP T-Day 20

    View full-size slide

  21. Mocks Vs Stubs
    Mock objects are used to define expectations
    Mocks record and verify such expectations.
    Stubs do not record or verify expectations, but rather allow us
    to “replace” the behavior, state of the “fake”object in order to
    utilize a test scenario
    Code4Hire, 2014, PHP T-Day 21

    View full-size slide

  22. Code4Hire, 2014, PHP T-Day 22

    View full-size slide

  23. Pixels & Deadlines
    Code4Hire, 2014, PHP T-Day 23

    View full-size slide

  24. Web Testing
    Code4Hire, 2014, PHP T-Day 24

    View full-size slide

  25. Web Testing
    • Goutte
    • Mink
    • Zombie.js
    • CasperJS
    • Codeception
    • Selenium
    Code4Hire, 2014, PHP T-Day 25

    View full-size slide

  26. Website recorder?
    Code4Hire, 2014, PHP T-Day 26

    View full-size slide

  27. Code4Hire, 2014, PHP T-Day 27

    View full-size slide

  28. Continuous Integration
    Code4Hire, 2014, PHP T-Day 28

    View full-size slide

  29. Continuous Integration
    • Jenkins
    • Bamboo
    • Travis
    • TeamCity
    • Semaphore
    Code4Hire, 2014, PHP T-Day 29

    View full-size slide

  30. Code4Hire, 2014, PHP T-Day 30

    View full-size slide

  31. Final Level
    Code4Hire, 2014, PHP T-Day 31

    View full-size slide

  32. Final Level
    Code4Hire, 2014, PHP T-Day 32

    View full-size slide

  33. Final Level
    Code with no tests,
    is worse than code with bad tests,
    is worse than code with some tests,
    is worse than code with all the tests
    Code4Hire, 2014, PHP T-Day 33

    View full-size slide

  34. Final Level
    Hunting for the 100% code coverage most of the times is
    impractical,
    but getting it to more than 0% is attainable goal.
    Code4Hire, 2014, PHP T-Day 34

    View full-size slide

  35. Final Level
    You are always a student, never a master.
    You have to keep moving forward.
    — Conrad Hall
    Code4Hire, 2014, PHP T-Day 35

    View full-size slide

  36. The End
    Thank You!
    Questions?
    https://joind.in/12412
    Code4Hire, 2014, PHP T-Day 36

    View full-size slide

  37. Links:
    https://github.com/FriendsOfPHP/Goutte
    https://github.com/Behat/en-mink.behat.org/blob/master/
    index.rst
    http://zombie.labnotes.org/
    http://casperjs.org/
    http://codeception.com/
    http://www.seleniumhq.org/
    http://sahipro.com/
    Code4Hire, 2014, PHP T-Day 37

    View full-size slide

  38. Links:
    https://chrome.google.com/webstore/detail/resurrectio/
    kicncbplfjgjlliddogifpohdhkbjogm?hl=en
    http://www.seleniumhq.org/projects/ide/
    Code4Hire, 2014, PHP T-Day 38

    View full-size slide

  39. Links:
    http://jenkins-ci.org/
    https://www.atlassian.com/software/bamboo
    https://travis-ci.org/
    https://www.jetbrains.com/teamcity/
    https://semaphoreapp.com/
    Code4Hire, 2014, PHP T-Day 39

    View full-size slide