The basic class structure
By using the SimpleTest framework the Drupal tests are defined as classes in object oriented style. Here is a skeleton test:
<?php
/**
* Example test file for My Module.
*/
class MyModuleCoolFeatureTest extends DrupalWebTestCase {
function getInfo() {
return array(
'name' => t('CoolFeature Test'),
'description' => t('Assure that all cool features of your module work.'),
'group' => t('MyModule Tests'),
);
}
function testMyCoolFeature() {
// Test code goes here. Notice you have to have your test method names begin with lowercase 'test'.
}
}
?>Getting started
When a test case runs it will search for any method that starts with the lowercase string 'test' and execute that method.
Your new class must also implement a method named getInfo():
It returns an associative array with your test's name, description, and which 'group' it belongs to. You may create a new group or insert your test into an existing group by using the same name.
This would go into a .test file, in your contributed module's 'tests' subdirectory.
