Testing With
At our Meetup in October, it was all about testing. Our PHP developer Alexander dealt intensively with Laravel PEST and provided some interesting facts about testing in general as well as insights into a concrete project.
PEST is a PHP testing framework for Laravel. But why is testing so important? On average, a developer creates up to 70 bugs per 1,000 lines of code (source: Coralogix 2015). Of these, 15 eventually find their way to the customer. Fixing bugs takes up to 30 times longer than writing code. Most developers will know this from their everyday lives. It is therefore not surprising that developers spend about 75% of their time fixing these bugs, losing 1,500 hours a year and a corresponding budget of 113 billion in the US alone. This can be counteracted by testing.
Other advantages of testing are higher quality and easier maintainability of code. In addition, code can be documented and it is easier for new developers to get started with projects. The similarity of PEST to widely used frontend testing frameworks such as Jest also makes testing easier, especially for beginners. In addition, boilerplate code is reduced, which makes the tests clearer.
Despite all these advantages, testing is unfortunately often neglected in practice, as it makes development more time-consuming and requires a certain amount of experience.
PEST was developed by Nuno Maduro - Laravel Core developer - to make testing easier and more integrable into everyday life.
Everything is simply integrated into a project via a composer require command. For Laravel, the Laravel plugin for PEST should also be installed, which enables access to the Laravel-specific test API. While in PHPUnit tests are written in classes, in PEST functions are used. These accept two arguments. A string describing the test and a closure with the actual test logic.
Tests with PEST can usually be divided into three phases:
To execute the tests, the ./vendor/bin/pest command or in Laravel - php artisan test is used.
The recording of the entire Meetup, including an example project, is available in the video.
Content & PR Management
Lea Auerbach
More on Laravel Meetup
Laravel DACH Meetup
Laravel Scout
At the Laravel DACH Meetup in May, Jure Knezovic addressed a simple, driver-based solution for full-text searches in Eloquent models.
Laravel DACH Meetup
Laravel Telescope and Version 9.0
Just in time for the start of spring in March, we kicked off the 2022 Meetup season with our two speakers Marcel Wege and Joshua Blum. You can find the recap here.
Would you also like to be a
speaker at our Meetup?
Contact us!