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

Designing Functional Tests

Designing Functional Tests

How to design functional tests to catch problems before your customers do.

Presented at PHP Surrey on 3rd Feb 2016.

Stuart Herbert

February 03, 2016
Tweet

More Decks by Stuart Herbert

Other Decks in Programming

Transcript

  1. Logic User Database Network Logic Logic Network UI & API

    UI & API UI & API Local Storage Local Storage Local Storage
  2. @GanbaroDigital Break Down Your App • User interface & API

    • Processing logic • Anything stored on the local machine
  3. Logic User Database Network Logic Logic Network UI & API

    UI & API UI & API Local Storage Local Storage Local Storage
  4. Logic User Database Network Logic Logic Network UI & API

    UI & API UI & API Local Storage Local Storage Local Storage
  5. Logic User Database Network Logic Logic Network UI & API

    UI & API UI & API Local Storage Local Storage Local Storage
  6. @GanbaroDigital The effectiveness of BDD testing is inversely proportional to

    the number of moving parts in your app’s architecture.
  7. @GanbaroDigital BDD testing cares that 
 something can be done.

    Functional tests care that 
 something has been done 
 accurately & completely.
  8. @GanbaroDigital BDD testing cares that 
 something can be done.

    Functional tests care that 
 something has been done 
 accurately & completely.
  9. Logic Database Network Logic Logic Network UI & API UI

    & API UI & API Local Storage Local Storage Local Storage User
  10. Logic Database Network Logic Logic Network UI & API UI

    & API UI & API Local Storage Local Storage Local Storage Actor
  11. Logic Database Network Logic Logic Network UI & API UI

    & API UI & API Local Storage Local Storage Local Storage Actor
  12. @GanbaroDigital For example: 
 if your actor uses a web

    browser, the functional test 
 must use a web browser.
  13. @GanbaroDigital For example: 
 if your actor uses 
 a

    specific client library, the functional test must use the same client library.
  14. Logic Database Network Logic Logic Network UI & API UI

    & API UI & API Local Storage Local Storage Local Storage Actor
  15. Logic Database Network Logic Logic Network UI & API UI

    & API UI & API Local Storage Local Storage Local Storage Actor
  16. @GanbaroDigital For example: if your UI says payment has been

    taken, has the purchase been stored in your database?
  17. @GanbaroDigital Functional Tests • Start from a defined state •

    Perform one operation • Use the same tools as the actor • Result in another defined state • Prove that the target state is achieved
  18. @GanbaroDigital Functional Tests • Start from a defined state •

    Perform one operation • Use the same tools as the actor • Result in another defined state • Prove that the target state is achieved
  19. @GanbaroDigital Functional Tests • Start from a defined state •

    Perform one operation • Use the same tools as the actor • Result in another defined state • Prove that the target state is achieved
  20. @GanbaroDigital Functional Tests • Start from a defined state •

    Perform one operation • Use the same tools as the actor • Result in another defined state • Prove that the target state is achieved
  21. @GanbaroDigital Functional Tests • Start from a defined state •

    Perform one operation • Use the same tools as the actor • Result in another defined state • Prove that the target state is achieved
  22. @GanbaroDigital Functional Tests • Start from a defined state •

    Perform one operation • Use the same tools as the actor • Result in another defined state • Prove that the target state is achieved
  23. @GanbaroDigital Wording A Functional Test • “Given <starting conditions>” •

    “Using <specific tool>” • “As <specific actor>” • “When I do <specific operation>” • “A <long list of things> happen” • “And I can now do 
 <a list of other things>”
  24. @GanbaroDigital Wording A Functional Test • “Given <starting conditions>” •

    “Using <specific tool>” • “As <specific actor>” • “When I do <specific operation>” • “A <long list of things> happen” • “And I can now do 
 <a list of other things>”
  25. @GanbaroDigital Wording A Functional Test • “Given <starting conditions>” •

    “Using <specific tool>” • “As <specific actor>” • “When I do <specific operation>” • “A <long list of things> happen” • “And I can now do 
 <a list of other things>”
  26. @GanbaroDigital Wording A Functional Test • “Given <starting conditions>” •

    “Using <specific tool>” • “As <specific actor>” • “When I do <specific operation>” • “A <long list of things> happen” • “And I can now do 
 <a list of other things>”
  27. Logic Database Network Logic Logic Network UI & API UI

    & API UI & API Local Storage Local Storage Local Storage Actor
  28. @GanbaroDigital Wording A Functional Test • “Given <starting conditions>” •

    “Using <specific tool>” • “As <specific actor>” • “When I do <specific operation>” • “A <long list of things> happen” • “And I can now do 
 <a list of other things>”
  29. Logic Database Network Logic Logic Network UI & API UI

    & API UI & API Local Storage Local Storage Local Storage Actor
  30. @GanbaroDigital Wording A Functional Test • “Given <starting conditions>” •

    “Using <specific tool>” • “As <specific actor>” • “When I do <specific operation>” • “A <long list of things> happen” • “And I can now do 
 <a list of other things>”
  31. @GanbaroDigital As A Code Flow • Test setup • Pre-test

    inspection • Action(s) • Post-test inspection • Test tear down
  32. @GanbaroDigital As A Code Flow • Test setup • Pre-test

    inspection • Action(s) • Post-test inspection • Test tear down
  33. @GanbaroDigital As A Code Flow • Test setup • Pre-test

    inspection • Action(s) • Post-test inspection • Test tear down
  34. @GanbaroDigital As A Code Flow • Test setup • Pre-test

    inspection • Action(s) • Post-test inspection • Test tear down
  35. @GanbaroDigital As A Code Flow • Test setup • Pre-test

    inspection • Action(s) • Post-test inspection • Test tear down
  36. Would you like to 
 know more? We can help.

    Stuart Herbert ~ @stuherbert Founder @GanbaroDigital