PestPHP Released as Open-Source
Published on by Paul Redmond
Console legend Nuno Maduro has open-sourced Pest, an elegant PHP testing framework that focuses on simplicity.
Goal reached: 75 @github sponsors. And as promised, @pestphp is now open-source and available for everyone.
– [x] Documentation: https://t.co/E4BRxvAu1g.
– [x] Source code: https://t.co/EVkbPuTGQn.Hope you enjoy this minimal & elegant PHP testing framework!
— NUNO MADURO (@enunomaduro) May 20, 2020
Here’s a quick example of what you can expect, which will be familiar to use if you’ve used other testing tools like Mocha or Jest:
test('asserts true is true', function () { assertTrue(true);}); // orit('asserts true is true', function () { assertTrue(true);});
Under the hood, Pest tests are bound to a test-case class (PHPUnit’s TestCase
by default), which means your closures run in the context of the configured test case:
it('has home', function () { $this->assertTrue(true); // \PHPUnit\Framework\TestCase echo get_class($this);});
Be sure to check out the documentation on how can customize the underlying test case via the uses()
function that Pest provides.
Be sure to read the Laravel Guide to learn how to create tests with Pest in a Laravel application. Here’s a sneak peek at using a higher-order test with Laravel:
use Tests\Feature;use Illuminate\Foundation\Testing\DatabaseMigrations; uses(TestCase::class, DatabaseMigrations::class); it('has home page') ->get('/') ->see('Laravel.io') ->see('The Laravel Community Portal');
Learn More
Check out PestPHP documentation to start using Pest, and view the source code on GitHub at pestphp/pest. . Pest also has guides for Symfony and PHPUnit. Finally, consider sponsoring Nuno for his excellent work on Pest, Laravel Zero, collision, and Larastan!