Home > Article > Backend Development > Official open source elegant testing framework PestPHP
Console legend Nuno Maduro has open sourced Pest, an elegant PHP testing framework that focuses on simplicity.
Here is a simple example, If you have used other testing tools, such as Mocha or Jest, you will feel familiar with it:
test('asserts true is true', function () { assertTrue(true); }); // or it('asserts true is true', function () { assertTrue(true); });
Under the hood, Pest tests are bound to a test case class (PHPUnit's TestCase by default) , this means that your closure function will run in the environment where the test case is configured:
it('has home', function () { $this->assertTrue(true); // \PHPUnit\Framework\TestCase echo get_class($this); });
Be sure to check out the documentation on how to customize the underlying test case through the uses() function provided by Pest.
Before you start, please make sure you have read the Laravel Guide to understand how to use Pest to create tests in Laravel. The following is a test for 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');
Recommended tutorial: "PHP Tutorial》
The above is the detailed content of Official open source elegant testing framework PestPHP. For more information, please follow other related articles on the PHP Chinese website!