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

Getting the most of PHPUnit assertions

Gabriel Caruso
September 07, 2019

Getting the most of PHPUnit assertions

Do you know, when you are writing a test, something isn't going right and you get a failure message "Failed asserting that false is true"? Let's see how we can improve our test's assertion in other to get more helpful errors by using dedicated PHPUnit assertions. We're going to see how we can make our suite of tests stricter, avoiding PHP's false-positives weakness. Also, we'll be seeing how PHPUnit works under the hood, from the assertion method to the verification itself.

Gabriel Caruso

September 07, 2019

More Decks by Gabriel Caruso

Other Decks in Technology


  1. Who am I? • Backend Developer at Usabilla • PHP

    Core Member • Community(ies) member • OSS contributor • Refactor/Stickers/ELEPHANTS lover
  2. Assertions Test Framework way to check if a result of

    something matches an expectation.
  3. Recap What does happen under the hood to PHPUnit judge

    assertEquals? $expected == $actual
  4. How do I know if I am using the best

    assertion for each test?
  5. Tools that you can use to automate these refactorings -

    FriendsOfPHP/PHP-CS-F ixer - rectorphp/rector