Upal - a proposed test framework for Drupal 8

Posted by
on December 12, 2011

Meet Upal. UPal is a PHPUnit based test framework for Drupal. I hope it can replace Simpletest as the test runner in Drupal 8. It aims to run all existing tests with little or no modification. To do so, it provides DrupalWebTestCase and DrupalUnitTestCase classes which are built upon PHPUnit instead of Drupal’s Simpletest.


  1. In my opinion, there is an intractable problem with Simpletest. Namely, even experienced developers get confused between the two Drupal sites that are in use during a test run. Those two sites are the Tester and ‘System Under Test’ (SUT). Simpletest takes heroic measures to isolate the SUT but we still are fighting fatal leakages between the two sites (e.g. all tables get deleted from tester, tester database can't be reached. Note that Simpletest 7.x-2.0 has Remote Test but that still involves two Drupals. With UPal, there is only one Drupal site - the SUT. I believe that this confusion severely reduce the pool of people who are willing and able to contribute patches to Drupal core.
  2. PHPUnit is the de facto standard for unit testing PHP apps. It is integrated into all the major IDEs (PHPStorm, NetBeans, Komodo, Eclipse), CI platforms like Jenkins, and has Selenium support built in. Most folks run PHPUnit from the command line, but VisualPHPUnit also does the job in a browser. PHPUnit has a great manual. We'll attract more talented PHP developers by moving to PHPUnit.

Next Steps - Coders needed

PHPUnit (sensibly) assumes that each test file only contains one test class. So it is not running subsequent test classes when Drupal has more than one in same file. We either need to compose our own test suite, or move subsequent classes to own in order overcome this limitation. Moving classes is probably more sensible, given our PSR-0 efforts. Let's discuss in that issue.

Upal is currently much faster than Simpletest because it restores an archived, empty Drupal site for each class, instead of installing from scratch. We can use drush’s archive-dump and archive-restore here instead of hard coding a DB dump from Drupal 7.4. That is how Drush’s test suite works. If we need to, we can just reinstall from scratch like Simpletest. I'm happy to take on this piece. Simpletest also do the ‘reinstall from sql file’ technique, so this isn’t an argument for Upal.

We also need to scope a plan for using Upal at http://qa.drupal.org. I think this isn’t too hard. We can get the test bots to send back the same XML that they send today. All the dispatching to test bots and communicating with drupal.org remains the same.


Drupal old timers might recall that I started the Simpletest project and maintained it for a four years. Since then, I feel like the father who watches his kid go out on a big bender. Simpletest has exceeded my dreams in many ways (30,000 assertions in Drupal core, automated testing of core and contrib patches), but it also broke some bones and sufferred head trauma along the way. Upal is my proposal for preserving the tests, while modernizing the framework.

Sign up for our developer Blog Newsletter


Add comment

By submitting this form, you accept the Mollom privacy policy.