bg_image
header

PEST

PEST is a modern testing framework for PHP that focuses on clean syntax, readability, and developer experience. It builds on PHPUnit but provides a much more expressive and minimalistic interface.

📌 PEST = "PHP Testing for Humans"
It’s designed for developers who want to write fast, readable, and elegant tests — with less boilerplate.


🚀 Why Use PEST Instead of PHPUnit?

PEST is built on top of PHPUnit, but it:

  • Provides a cleaner, simpler syntax

  • Removes unnecessary structure

  • Encourages a functional, behavior-driven style

  • Still supports traditional PHPUnit classes if needed


🔍 Example – PHPUnit vs. PEST

PHPUnit:

class UserTest extends TestCase
{
    public function test_user_has_name()
    {
        $user = new User('John');
        $this->assertEquals('John', $user->name);
    }
}

PEST:

it('has a name', function () {
    $user = new User('John');
    expect($user->name)->toBe('John');
});

👉 Much shorter and easier to read — especially when writing many tests.


🧩 Key Features of PEST

  • ✅ Elegant, expressive syntax (inspired by Jest/Mocha)

  • 🧪 Supports unit, feature, API, and browser-based testing

  • 🧱 Data-driven testing via with([...])

  • 🧬 Test hooks like beforeEach() / afterEach()

  • 🎨 Fully extensible with plugins and custom expectations

  • 🔄 Fully compatible with PHPUnit — you can run both side by side


🛠️ Installation

In a Laravel or Composer project:

composer require pestphp/pest --dev
php artisan pest:install  # for Laravel projects

Then run tests:

./vendor/bin/pest

🧠 Summary

PEST is ideal if you:

  • Want to write tests that are fun and easy to maintain

  • Prefer clean, modern syntax

  • Already use PHPUnit but want a better experience

💡 Many Laravel developers are adopting PEST because it integrates seamlessly with Laravel and truly makes testing feel "human" — just like its slogan says.


Random Tech

Doctrine Database Abstraction Layer - DBAL


doctrine-logo-6B6BF1A613-seeklogo.com.png