SKILL

laravel-tdd

Laravel での TDD:PHPUnit と Pest、ファクトリー、データベーステスト、フェイク、カバレッジターゲット

Original · translation did not pass checks

Target: Software development & testing. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Japanese text

Topics in the source

  • Laravel TDD ワークフロー
  • 使用時機
  • 仕組み
  • RED-GREEN-REFACTOR サイクル
  • テスト層
  • データベース戦略
  • テストフレームワーク選択
  • 例

PHPUnit と Pest を使用した Laravel アプリケーション用のテスト駆動開発。80%+ カバレッジ(ユニット + フィーチャー)。 Laravel の新機能またはエンドポイント バグ修正またはリファクタリング Eloquent モデル、ポリシー、ジョブ、通知のテスト プロジェクトが PHPUnit を標準化していない限り、新しいテストには Pest を優先 1) テスト失敗を書く 2) 最小限の変更を実装して合格させる 3) テストを緑に保ちながらリファクタリング ユニット:純粋な PHP クラス、値オブジェクト、サービス フィーチャー:HTTP エンドポイント、認証、バリデーション、ポリシー 統合:データベース + キュー + 外部バウンダリー スコープに基づいて層を選択: ユニットテストを純粋なビジネスロジックとサービスに使用。 フィーチャーテストを HTTP、認証、バリデーション、レスポンス形状に使用。 統合テストを DB/キュー/外部サービスを一緒に検証するときに使用。 RefreshDatabase ほとんどのフィーチャー/統合テスト用(テスト実行ごとにマイグレーションを 1 回実行し、次に各テストをトランザクション内でラップ;メモリ内データベースは各テストごとに再マイグレーションする可能性がある) DatabaseTransactions スキーマがすでにマイグレーションされており、テストごとのロールバックのみが必要なとき DatabaseMigrations すべてのテストで完全な migrate/fresh が必要なとき、またはコストを負担できるとき RefreshDatabase をデータベースに触れるテストのデフォルトとして使用:トランザクション サポート付きデータベースの場合、マイグレーション ステップ フラグを使用して テスト実行ごとに 1 回実行し、次に各テストをトランザクション内でラップします;:memory: SQLite または非トランザクションの接続では、各テストの前にマイグレーションします。スキーマがすでにマイグレーションされており、テストごとのロールバックのみが必要なときは DatabaseTransactions を使用します。 新しいテストの場合は Pest をデフォルトで使用。 PHPUnit はプロジェクトがすでにそれを標準化している、またはPHPUnit 固有のツールが必要なときのみ使用。 テストデータにはファクトリーを使用 エッジケース(アーカイブ済み、管理者、トライアル)の状態を定義 クリーンな状態には RefreshDatabase を使用 テストを隔離して決定論的に保つ 手動クエリより assertDatabaseHas を優先 Bus::fake() ジョブ用 Queue::fake(

This is an excerpt. Refer to the complete source and its current requirements.

Source repository
affaan-m/ECC
Source file
docs/ja-JP/skills/laravel-tdd/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T14:01:49.407Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.