Intro to SimpleTest
- Drupal's custom testing framework.
- Creates a separate instance of Drupal for testing.
- Automate tests.
Setup
- CURL extension for PHP
- PHP open_basedir restriction needs to be disabled.
- DOM extension for PHP. DOM support is included by default in php5.
- Recommended PHP memory limit of 256MB.
Running Tests
-
Via Web UI
- Enable Testing module.
- Access admin/config/development/testing.
- Select a group to test
- Press Run tests.
- Via ./scripts/run-tests.sh.
- Via drush test-run.
DrupalWebTestCase
Creates a fresh installation of Drupal with tables in a prefix simpletest* and has a virtual browser.
DrupalWebTestCase
class ExampleTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'Name',
'description' => 'Description',
'group' => 'Group',
);
}
public function setUp() {
parent::setUp('example_module');
}
}
DrupalUnitTestCase
Doesn't create tables, and is lighter and faster.
DrupalUnitTestCase
class ExampleUnitTestCase extends DrupalUnitTestCase {
public static function getInfo() {
return array(
'name' => 'Name',
'description' => 'Description',
'group' => 'Group',
);
}
public function setup() {
drupal_load('module', 'example_module');
parent::setUp();
}
}
Web Test Cases
- Employee CRUD
- Department CRUD
- Overview Page Access
Unit Test Cases
- Employee Positions
- Salary Validation
- SalaryDeduction