Index: modules/simpletest/simpletest.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.module,v
retrieving revision 1.3
diff -u -r1.3 simpletest.module
--- simpletest.module	10 May 2008 07:46:22 -0000	1.3
+++ simpletest.module	3 Jun 2008 18:12:22 -0000
@@ -94,6 +94,11 @@
 
 function simpletest_running_output($output = NULL) {
   static $o;
+  if (isset($_SESSION['simpletest_results'])) {
+    $o = $_SESSION['simpletest_results'];
+    drupal_add_js('misc/collapse.js');
+    unset($_SESSION['simpletest_results']);
+  }
   if ($output != NULL) {
     $o = $output;
   }
@@ -387,7 +392,7 @@
   static $test_running;
   if (!$test_running) {
     $test_running = TRUE;
-    $test = simpletest_get_total_test($test_list);
+    $tests = simpletest_get_total_test($test_list);
     switch ($reporter) {
       case 'text':
         $reporter = &new TextReporter();
@@ -402,19 +407,77 @@
         $reporter = &new DrupalReporter();
         break;
     }
+    
+    $operations = array();
+    for ($i = 0; $i < count($tests->_test_cases); $i++) {
+      $operations[] = array('_simpletest_batch_operation', array(serialize($tests), serialize($reporter)));
+    }
 
     cache_clear_all();
-    $results = $test->run($reporter);
-    $test_running = FALSE;
 
-    switch (get_class($reporter)) {
-      case 'TextReporter':
-      case 'XMLReporter':
-      case 'HtmlReporter':
-        return $results;
-      case 'DrupalReporter':
-        return $reporter->getOutput();
-    }
+    $batch = array(
+      'title' => t('Running SimpleTests'),
+      'operations' => $operations,
+      'finished' => '_simpletest_batch_finished',
+    );
+    batch_set($batch);
+  }
+}
+
+/**
+ * Batch operation callback.
+ */
+function _simpletest_batch_operation($tests, $reporter, &$context) {
+  simpletest_get_total_test();
+  if (!isset($context['sandbox']['tests'])) {
+    $tests = unserialize($tests);
+  }
+  else {
+    $tests = unserialize($context['sandbox']['tests']);
+  }
+  if (!isset($context['sandbox']['reporter'])) {
+    $reporter = unserialize($reporter);
+  }
+  else {
+    $reporter = unserialize($context['sandbox']['reporter']);
+  }
+  if (empty($context['sandbox'])) {
+    // Initiate multistep processing.
+    $context['sandbox']['progress'] = 0;
+    $context['sandbox']['max'] = count($tests->_test_cases);
+  }
+
+  drupal_set_message('Running!');
+  $results = $tests->runOnce($reporter);
+  $context['sandbox']['progress']++;
+  
+  switch (get_class($reporter)) {
+    case 'TextReporter':
+    case 'XMLReporter':
+    case 'HtmlReporter':
+       $result = $results;
+    case 'DrupalReporter':
+      $result = $reporter->getOutput();
+  }
+
+  $context['sandbox']['reporter'] = serialize($reporter);
+  $context['sandbox']['tests'] = serialize($tests);
+
+  // Multistep processing : report progress.
+  if ($context['sandbox']['progress'] != $context['sandbox']['max']) {
+    $context['finished'] = $context['sandbox']['progress'] / $context['sandbox']['max'];
+  }
+  $context['results'][] = $result;
+  $context['message'] = 'Test successfully completed.';
+}
+
+function _simpletest_batch_finished($success, $results, $operations) {
+  if ($success) {
+    $_SESSION['simpletest_results'] = implode('', $results);
+    drupal_set_message(t('The tests have finished running.'));
+  }
+  else {
+    drupal_set_message(t('The tests did not successfully finish.'), 'error');
   }
 }
 
@@ -473,5 +536,4 @@
   );
 
   return system_settings_form($form);
-
 }
Index: modules/simpletest/test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/test_case.php,v
retrieving revision 1.3
diff -u -r1.3 test_case.php
--- test_case.php	10 May 2008 06:55:09 -0000	1.3
+++ test_case.php	3 Jun 2008 17:02:52 -0000
@@ -509,6 +509,20 @@
     return $reporter->getStatus();
   }
 
+  function runOnce(&$reporter) {
+    $reporter->paintGroupStart($this->getLabel(), $this->getSize());
+    $test = array_shift($this->_test_cases);
+    if (is_string($test)) {
+      $test = &new $test();
+      $test->run($reporter);
+    }
+    else {
+      $test->run($reporter);
+    }
+    $reporter->paintGroupEnd($this->getLabel());
+    return $reporter->getStatus();
+  }
+
   /**
    *    Number of contained test cases.
    *    @return integer     Total count of cases in the group.
