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

Test to Break Principles

Rob Waller
February 01, 2019

Test to Break Principles

There are two types of tests a developer can write, ‘test to work’ and ‘test to break’. Both are essential to robust development, but many developers only use the former and not the latter. This talk explains why ‘test to break’ principles are essential to ensure robust application development.

Rob Waller

February 01, 2019
Tweet

More Decks by Rob Waller

Other Decks in Technology

Transcript

  1. W: rbrt.wllr.info | T: @RobDWaller
    Test to Break
    Principles
    Why You Should Crash Your Car Into a Tree

    View Slide

  2. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  3. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  4. W: rbrt.wllr.info | T: @RobDWaller
    What is a Unit Test?

    View Slide

  5. W: rbrt.wllr.info | T: @RobDWaller
    3 Types of Test

    View Slide

  6. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  7. W: rbrt.wllr.info | T: @RobDWaller
    TDD Tips
    Test Business Logic
    Test Private Methods
    Test Input / Output
    Test Big Methods
    Do Don’t

    View Slide

  8. W: rbrt.wllr.info | T: @RobDWaller
    Test to Work

    View Slide

  9. W: rbrt.wllr.info | T: @RobDWaller
    Example 1.
    Given the driver has a valid car key.
    When they insert the key into the ignition.
    And they turn the key.
    Then the car's engine starts.

    View Slide

  10. W: rbrt.wllr.info | T: @RobDWaller
    Example 2.
    Given the driver has an invalid car key.
    When they insert the key into the ignition.
    And they turn the key.
    Then the car's engine will not start.

    View Slide

  11. W: rbrt.wllr.info | T: @RobDWaller
    Test to Break

    View Slide

  12. W: rbrt.wllr.info | T: @RobDWaller
    Example 1.
    Given the driver has a screwdriver.
    When they insert it into the ignition.
    And turn the screwdriver.
    Then the car's engine will not start.

    View Slide

  13. W: rbrt.wllr.info | T: @RobDWaller
    Example 2.
    Given a car is traveling at 30 mph.
    When it hits a tree.
    Then all the seat belts tighten.
    And the airbags deploy.

    View Slide

  14. W: rbrt.wllr.info | T: @RobDWaller
    Code Example

    View Slide

  15. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  16. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  17. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  18. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  19. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  20. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  21. W: rbrt.wllr.info | T: @RobDWaller
    Good software
    functions well and
    is bug free.

    View Slide

  22. W: rbrt.wllr.info | T: @RobDWaller
    Ignorance Complexity

    View Slide

  23. W: rbrt.wllr.info | T: @RobDWaller
    Ignorance is natural
    Complexity is standard
    Test to break helps

    View Slide

  24. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  25. W: rbrt.wllr.info | T: @RobDWaller
    Rules
    1. Cars can only be black.
    2. Cars can have two or four doors.
    3. Cars must have four wheels.

    View Slide

  26. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  27. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  28. W: rbrt.wllr.info | T: @RobDWaller
    Summary
    ‘Working’ software is not good enough.
    Writing good software is hard.
    You are ignorant.
    Your problems are complicated.
    Always write tests.
    Stress and break your business logic.
    Code will work in one way always.

    View Slide

  29. W: rbrt.wllr.info | T: @RobDWaller

    View Slide

  30. W: rbrt.wllr.info | T: @RobDWaller
    Rob Waller
    T: @RobDWaller
    W: rbrt.wllr.info

    View Slide