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 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 Slide

  3. Code4Hire, 2014, PHP T-Day 3

    View Slide

  4. Code4Hire, 2014, PHP T-Day 4

    View Slide

  5. Code4Hire, 2014, PHP T-Day 5

    View Slide

  6. Code4Hire, 2014, PHP T-Day 6

    View Slide

  7. Code4Hire, 2014, PHP T-Day 7

    View Slide

  8. Code4Hire, 2014, PHP T-Day 8

    View Slide

  9. Code4Hire, 2014, PHP T-Day 9

    View Slide

  10. Code4Hire, 2014, PHP T-Day 10

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View 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 Slide

  22. Code4Hire, 2014, PHP T-Day 22

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide

  27. Code4Hire, 2014, PHP T-Day 27

    View Slide

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

    View Slide

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

    View Slide

  30. Code4Hire, 2014, PHP T-Day 30

    View Slide

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

    View Slide

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

    View 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 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 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 Slide

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

    View 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 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 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 Slide