summaryrefslogtreecommitdiff
path: root/modules/simpletest/drupal_web_test_case.php
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-11-26 19:26:57 +0000
committerDries Buytaert <dries@buytaert.net>2010-11-26 19:26:57 +0000
commit385bf02ca3104a0c363a216bb3a6661a7d085864 (patch)
tree9404a250870315c686906e9bac5acf27b50aa0c8 /modules/simpletest/drupal_web_test_case.php
parent2fdc28d0f0a0792f604d1e328968e281fce2bfd4 (diff)
downloadbrdo-385bf02ca3104a0c363a216bb3a6661a7d085864.tar.gz
brdo-385bf02ca3104a0c363a216bb3a6661a7d085864.tar.bz2
- Patch #916570 by sun, klausi: allow to run only certain test methods.
Diffstat (limited to 'modules/simpletest/drupal_web_test_case.php')
-rw-r--r--modules/simpletest/drupal_web_test_case.php20
1 files changed, 17 insertions, 3 deletions
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 1949b99a5..c5c63d8c5 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -431,8 +431,17 @@ abstract class DrupalTestCase {
/**
* Run all tests in this class.
+ *
+ * Regardless of whether $methods are passed or not, only method names
+ * starting with "test" are executed.
+ *
+ * @param $methods
+ * (optional) A list of method names in the test case class to run; e.g.,
+ * array('testFoo', 'testBar'). By default, all methods of the class are
+ * taken into account, but it can be useful to only run a few selected test
+ * methods during debugging.
*/
- public function run() {
+ public function run(array $methods = array()) {
// Initialize verbose debugging.
simpletest_verbose(NULL, variable_get('file_public_path', conf_path() . '/files'), get_class($this));
@@ -447,8 +456,13 @@ abstract class DrupalTestCase {
set_error_handler(array($this, 'errorHandler'));
$class = get_class($this);
- // Iterate through all the methods in this class.
- foreach (get_class_methods($class) as $method) {
+ // Iterate through all the methods in this class, unless a specific list of
+ // methods to run was passed.
+ $class_methods = get_class_methods($class);
+ if ($methods) {
+ $class_methods = array_intersect($class_methods, $methods);
+ }
+ foreach ($class_methods as $method) {
// If the current method starts with "test", run it - it's a test.
if (strtolower(substr($method, 0, 4)) == 'test') {
// Insert a fail record. This will be deleted on completion to ensure