Index: modules/simpletest/simpletest.module
===================================================================
--- modules/simpletest/simpletest.module	2008-09-15 16:53:16.000000000 +0200
+++ modules/simpletest/simpletest.module	2008-09-15 16:53:27.000000000 +0200
@@ -61,6 +61,8 @@
   $form = array();
   $uncategorized_tests = simpletest_get_all_tests();
   $tests = simpletest_categorize_tests($uncategorized_tests);
+  $selected_tests = array();
+
   if (isset($_SESSION['test_id'])) {
     // Select all results using the active test ID used to group them.
     $results = db_query("SELECT * FROM {simpletest} WHERE test_id = %d ORDER BY test_class, message_id", $_SESSION['test_id']);
@@ -85,6 +87,7 @@
       $class = $result->test_class;
       $info = $uncategorized_tests[$class]->getInfo();
       $group = $info['group'];
+      $selected_tests[$group][$class] = TRUE;
       if (!isset($group_summary[$group])) {
         $group_summary[$group] = $summary;
       }
@@ -151,15 +154,22 @@
     $form['summary']['#ok'] = $all_ok;
   }
   foreach ($tests as $group_name => $test_group) {
+    $form['tests'][$group_name] = array(
+      '#collapsed' => TRUE,
+    );
     foreach ($test_group as $test) {
       $test_info = $test->getInfo();
       $test_class = get_class($test);
+      $is_selected = isset($selected_tests[$group_name][$test_class]);
       $form['tests'][$group_name][$test_class] = array(
         '#type' => 'checkbox',
         '#title' => $test_info['name'],
-        '#default_value' => 0,
+        '#default_value' => $is_selected,
         '#description' => $test_info['description'],
       );
+      if ($is_selected) {
+        $form['tests'][$group_name]['#collapsed'] = FALSE;
+      }
     }
   }
 
@@ -221,6 +231,8 @@
   foreach (element_children($form['tests']) as $key) {
     $element = &$form['tests'][$key];
     $test_class = strtolower(trim(preg_replace("/[^\w\d]/", "-", $key)));
+    $collapsed = !empty($form['tests'][$key]['#collapsed']);
+    $image_index = $collapsed ? 0 : 1;
     $row = array();
     $row[] = array('id' => $test_class, 'class' => 'simpletest-select-all');
     $row[] = array(
@@ -230,7 +242,7 @@
     $row[] = isset($element['#description']) ? $element['#description'] : '&nbsp;';
     $rows[] = array('data' => $row, 'class' => 'simpletest-group');
 
-    $current_js = array('testClass' => $test_class .'-test', 'testNames' => array(), 'imageDirection' => 0, 'clickActive' => FALSE);
+    $current_js = array('testClass' => $test_class .'-test', 'testNames' => array(), 'imageDirection' => $image_index, 'clickActive' => FALSE);
     foreach (element_children($element) as $test_name) {
       $current_js['testNames'][] = 'edit-'. $test_name;
       $test = $element[$test_name];
@@ -244,7 +256,7 @@
       $row[] = $themed_test;
       $row[] = theme('indentation', 1) .'<label for="edit-'. $test_name .'">'. $title .'</label>';
       $row[] = '<div class="description">'. $description .'</div>';
-      $rows[] = array('data' => $row, 'class' => $test_class .'-test js-hide');
+      $rows[] = array('data' => $row, 'class' => $test_class .'-test' . ($collapsed ? ' js-hide' : ''));
     }
     $js['simpletest-test-group-'. $test_class] = $current_js;
   }
