Pest
Pest 對我來說提供了更便捷的測試方式和直譯式的寫法,類似 JS 相關的測試框架,同時又保留了 Laravel 和 PHP 龐大的輔助函數和功能。 official laracasts 主結構 $ composer require pestphp/pest --dev --with-all-dependencies $ ./vendor/bin/pest --init $ ./vendor/bin/pest folders: ├── 📂 tests │ ├── 📂 Unit │ │ └── ExampleTest.php │ └── 📂 Feature │ │ └── ExampleTest.php │ └── TestCase.php │ └── Pest.php ├── phpunit.xml 簡單示例 這邊可以自己添加 phpunit.xml 對應路徑,可以看到 Pest.php 實現細節: 這邊表示注入 TestCase 到 Feature 底下,可以使用 TestCase 裡面所提供的方法,當然也可以注入對應的方法到指定的 folder 底下: uses( Tests\TestCase::class, // Illuminate\Foundation\Testing\RefreshDatabase::class, )->in('Feature'); SumTest...