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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size 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 full-size 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 full-size slide

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

    View full-size 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 full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size 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 full-size slide

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

    View full-size slide

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

    View full-size slide