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 new Pest testing framework.

Pest offers a modern, expressive testing API which streamlines the process of writing tests. 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 4 hours.

Screenshot of a pull request with atomic commits for each change of the Pest Converter

Watch a demo

Requirements

  • A Laravel or PHP application
  • Running PHP 7.4 or higher
  • A phpunit/phpunit or pestphp/pest dependency

Conversions

The Pest Converter automates the following conversions:

  • Installs the latest version of Pest.
  • 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 annotations. While many of the common annotations are supported by Pest and converted by the Pest Converter, some are not. If you are using more complex PHPUnit annotations, 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.