Configs2026年5月19日·1 分钟阅读

Pest — Elegant PHP Testing Framework

Pest is a testing framework for PHP that focuses on simplicity and developer experience, offering an expressive syntax built on top of PHPUnit.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Pest Overview
通用 CLI 安装命令
npx tokrepo install d1ced1c9-53c0-11f1-9bc6-00163e2b0d79

Introduction

Pest brings a clean, minimal syntax to PHP testing inspired by Jest and RSpec. It wraps PHPUnit so existing test suites can adopt Pest incrementally without rewriting anything.

What Pest Does

  • Provides a fluent closure-based test syntax for PHP
  • Runs on top of PHPUnit with full compatibility
  • Offers built-in architecture testing for enforcing code rules
  • Supports parallel test execution and test profiling
  • Includes snapshot testing and type coverage analysis

Architecture Overview

Pest is a thin layer over PHPUnit that transforms its closure-based test() and it() calls into standard PHPUnit test cases at runtime. Test files are plain PHP scripts without class boilerplate. Pest discovers and loads them through its own test suite loader, then delegates execution to the PHPUnit engine.

Self-Hosting & Configuration

  • Install via Composer as a dev dependency
  • Initialize with ./vendor/bin/pest --init to scaffold config
  • Configure in pest.php or fall back to phpunit.xml
  • Use --parallel flag to run tests across multiple processes
  • Integrate with CI by running ./vendor/bin/pest --ci

Key Features

  • Minimal closure-based test syntax with zero class boilerplate
  • Architecture testing to enforce dependency and namespace rules
  • Built-in code coverage and type coverage reporting
  • Snapshot testing for complex output assertions
  • Parallel execution for faster test suite runs

Comparison with Similar Tools

  • PHPUnit — class-based tests with more ceremony; Pest wraps PHPUnit with a simpler API
  • Codeception — full-stack BDD testing; Pest focuses on unit and feature tests with less setup
  • PHPSpec — spec-driven design tool; Pest is a general-purpose test runner
  • Jest — JavaScript testing; Pest brings a similar developer experience to PHP
  • Behat — behavior-driven with Gherkin syntax; Pest uses plain PHP closures

FAQ

Q: Can I use Pest alongside existing PHPUnit tests? A: Yes. Pest is fully compatible with PHPUnit. Both styles can coexist in the same project.

Q: Does Pest support Laravel? A: Yes. The pestphp/pest-plugin-laravel package adds Laravel-specific helpers and assertions.

Q: Is Pest slower than PHPUnit? A: No. Pest adds negligible overhead since it delegates execution to PHPUnit internally.

Q: What PHP versions does Pest support? A: Pest v3 requires PHP 8.2 or higher.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产