Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.247
diff -u -p -r1.247 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	12 Nov 2010 03:06:52 -0000	1.247
+++ modules/simpletest/drupal_web_test_case.php	14 Nov 2010 07:06:10 -0000
@@ -75,6 +75,13 @@ abstract class DrupalTestCase {
   protected $skipClasses = array(__CLASS__ => TRUE);
 
   /**
+   * The name of the expected exception to be thrown during a test.
+   *
+   * @var string
+   */
+  protected $expectedException = '';
+
+  /**
    * Constructor for DrupalTestCase.
    *
    * @param $test_id
@@ -466,7 +473,12 @@ abstract class DrupalTestCase {
           // Finish up.
         }
         catch (Exception $e) {
-          $this->exceptionHandler($e);
+          if (get_class($e) == $this->getExpectedException()) {
+            $this->assertTrue(TRUE, "Expected exception '" . get_class($e) . "' thrown in test.");
+          }
+          else {
+            $this->exceptionHandler($e);
+          }
         }
         $this->tearDown();
         // Remove the completion check record.
@@ -479,6 +491,25 @@ abstract class DrupalTestCase {
   }
 
   /**
+   * Returns the expected exception for this test.
+   *
+   * @return string
+   */
+  public function getExpectedException() {
+    return $this->expectedException;
+  }
+
+  /**
+   * Sets the expected exception for this test.
+   *
+   * @param string $expectedException
+   * @return void
+   */
+  public function setExpectedException($expectedException) {
+    $this->expectedException = $expectedException;
+  }
+
+  /**
    * Handle errors during test runs.
    *
    * Because this is registered in set_error_handler(), it has to be public.
