oliverdavies.uk/source/_daily_emails/2024-01-20.md

1 KiB

title date permalink snippet tags
PHPUnit or Pest? 2024-01-20 daily/2024/01/20/phpunit-or-pest Which testing framework do you prefer? PHPUnit or Pest?
software-development
automated-testing
test-driven-development
php

A recent discussion has started about which testing framework should be the default one used in Laravel.

PHPUnit or Pest.

I've used both, and I like both.

I'm more familiar with classes, object-orientated code and PHPUnit, but for people who are more familiar with JavaScript and the Jest testing framework, Pest may be the better option.

Its expectation API, where you can chain multiple assertions on the same expectation, is helpful, although I don't mind some repetition in PHPUnit tests.

Pest tests can become abstract, especially with some of their one-line example tests.

Whether you pick PHPUnit, Pest or another framework like Behat or Codeception, the main thing is you're taking the time to write automated tests for your code, which is valuable whichever testing tool you use.