Skip to content

Drupal Test-Driven Development

Drupal 11.x | PHPUnit 10.5+

I need to...

Task Guide
Choose the right test type Test Type Decision Matrix
Apply RED-GREEN-REFACTOR cycle TDD Workflow: RED-GREEN-REFACTOR
Set up PHPUnit configuration PHPUnit Configuration
Write a unit test Unit Tests with UnitTestCase
Write a kernel test Kernel Tests with KernelTestBase
Write a browser test Browser Tests with BrowserTestBase
Write a JavaScript test JavaScript Tests with WebDriverTestBase
Use test traits Test Traits & Utilities
Create a test module Test Modules
Test a service Testing Services
Test a plugin Testing Plugins
Test a form Testing Forms
Test entities Testing Entities
Test permissions Testing Access & Permissions
Test routes/controllers Testing Routes & Controllers
Test configuration Testing Configuration
Test events/hooks Testing Events & Hooks
Apply TDD to Drupal modules Spec-Driven Drupal Development
Test JavaScript with Nightwatch Nightwatch.js Testing
Run tests Running Tests
Measure code coverage Coverage Metrics Strategy
Set up quality gates Quality Gates & Audit Checklist
Follow best practices Best Practices & Patterns
Avoid common mistakes Anti-Patterns & Common Mistakes
Find test resources Code Reference Map