How AI Transformed Drupal Testing: Lessons from a Real-World Experiment
When building a custom Drupal module for PDF generation, Laura Johnson from Four Kitchens set out to test whether AI could make automated testing faster and more accessible, even under deadline pressure. Her goal was to break the pattern of skipping tests due to time constraints and instead, see if AI could become a real-time development partner.
Initially, AI-generated tests offered speed by scaffolding PHPUnit structures and suggesting relevant logic. However, recurring oversights—like missing required modules or incorrect service mocking—meant manual corrections were still essential. To address this, Johnson created a custom ruleset using Cursor to guide the AI and improve consistency in test generation.
The blog outlines how different types of Drupal tests—unit, kernel, and functional—each posed unique challenges. Unit tests benefited most from AI assistance, while kernel and functional tests required careful setup, especially around schema installations and service mocking. Over time, her ruleset evolved into a reusable asset that helped the AI deliver more accurate test drafts with fewer corrections.

