Pro Yearly is on sale from $80 to $50! »

snapshot testing (phplimburg)

snapshot testing (phplimburg)

A1b4b398630bbd32b77a82cbc37fae9a?s=128

Freek Van der Herten

September 07, 2017
Tweet

Transcript

  1. A practical intro to snapshot testing and PHPUnit-watcher

  2. About me Freek Van der Herten Partner & developer at

    SPATIE Blogging at https://murze.be https://murze.be/newsletter
  3. OPEN SOURCE SOFTWARE

  4. https://spatie.be/en/opensource/laravel

  5. Open source software ± 160 public repositories on GitHub August

    2016: ± 800 000 downloads August 2017: ± 5 000 000 downloads ± 500 000 downloads a month
  6. LET’S TALK SNAPSHOT TESTING

  7. A file on disk, let’s call in snapshot Test succeeds

    if output matches snapshot If not, test will fail What?
  8. Another name: characterization testing Popularized by Facebook Jest Testing interfaces

    Where does it come from?
  9. https://github.com/spatie/phpunit-snapshot-assertions assertMatchesSnapshot assertMatchesJsonSnapshot assertMatchesXmlSnapshot How can we do it in

    PHP?
  10. DEMO

  11. WRAPPING UP

  12. Advantages Very easy to get started with Can be used

    to validate complex output Easily update all the tests in one go
  13. Disadvantages Brittle Hard to pinpoint exact point of failure Bugs

    can be easily written in the snapshots
  14. https://github.com/spatie/phpunit-snapshot-assertions https://sebastiandedeyne.com/posts/2017/a-package-for-snapshot- testing-in-phpunit https://murze.be/2017/04/practical-introduction-snapshot-testing/ https://www.sitepoint.com/snapshot-testing-viable-php/ https://facebook.github.io/jest/docs/snapshot-testing.html
 
 https://github.com/spatie/phpunit-watcher Interesting links

  15. Thank you! https://speakerdeck.com/freekmurze/snapshot-testing-phplimburg https://spatie.be/opensource https://murze.be https://murze.be/newsletter/

  16. QUESTIONS?