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

Test-driven development with PHPUnit

Test-driven development with PHPUnit

Oliver Klee

August 05, 2022
Tweet

More Decks by Oliver Klee

Other Decks in Programming

Transcript

  1. About me Oliver „Oli“ Klee #bonn #extension-dev #workshop-teacher #unit-testing-guy #phpstan-guy

    #typo3-ombudsperson #typo3-quality-assurance-initiative #gami fi cation-working-group #game-cooking #powermetal
  2. ???

  3. The goals ✓ You have a clearer understanding on how

    TDD works. ✓(optional) You get test-infected. ✓You learn at least 1 new testing pattern. ✓We all have fun.
  4. The travel plan 1. getting starte d 2. concepts &

    term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
  5. The travel plan 1. getting starte d 2. concepts &

    term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
  6. The life cycle of a test new FooTest(); setUp(); /**

    @test */ lifeIsGood(); tearDown();
  7. The travel plan 1. getting starte d 2. concepts &

    term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
  8. The travel plan 1. getting starte d 2. concepts &

    term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
  9. The travel plan 1. getting starte d 2. concepts &

    term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback
  10. Use meaningful test names classCanBeInstantiated setTitleSetsTitle setSizeWithZeroThrowsException hasTitleForEmptyTitleReturnsFalse Name the

    behavior. Name the preconditions. Name the method. Don’t use 
 “works” or 
 “works correctly”. measureFrubbleWorksCorrectly
  11. The travel plan 1. getting starte d 2. concepts &

    term s 3. testing pattern s 4. hands-o n 5. naming test s 6. hands-o n 7. ending & feedback