Shift with red gradient lettering

Pest Converter

The Pest Converter automates the process of converting your test suite from using the PHPUnit testing framework to use the Pest testing framework.

Pest offers a modern, expressive testing API allowing you to have a little more fun when writing tests.

After running the Pest Converter all of your PHPUnit test classes will be converted to Pest tests, giving you a single, unified test suite running Pest.

Using the Pest Converter to automatically convert your test suite has an estimated time savings of 3 hours.

Screenshot of a pull request with automated changes from the Pest Converter

Watch a demo

Requirements

  • A phpunit/phpunit dependency of 9.0 or higher (or pestphp/pest)
  • PHPUnit test classes under a tests/ folder
  • Running PHP 8.1 or higher

Automated Conversions

The Pest Converter automates the following conversions:

  • Installs the latest version of Pest (2.2).
  • Adds dependencies for additional Pest plugins like pestphp/pest-plugin-laravel.
  • Creates a default tests/Pest.php file.
  • Converts PHPUnit lifecycle methods to Pest beforeAll, beforeEach, afterEach, afterAll.
  • Converts test cases intelligently renaming the test description and choosing the test or it API.
  • Converts any data provider to a Pest dataset.
  • Maintains test groups by chaining Pest group().
  • Adopts fluent Pest expectations over PHPUnit assertions when available.
  • Updates your build pipeline to use the vendor/bin/pest runner instead of vendor/bin/phpunit.

Manual Conversions

PHPUnit allowed metaprogramming through DocBlock annotations and PHP attributes. While some of the common ones are supported by Pest and converted by the Pest Converter, many are not. If you are relying heavily on these in PHPUnit, you may rework these beforehand or preserve them as PHPUnit tests. Although the goal of the Pest Converter is to allow you to use Pest exclusively, you may still run PHPUnit and Pest tests together.

Sign in with any of the following services to connect Shift with your Laravel project.


Don't use one of these services?

Temporarily push your project to a free, private repository on one of these cloud-based services or upgrade your project locally with Shift for Docker.