Index: modules/simpletest/drupal_web_test_case.php
===================================================================
RCS file: /cvs/drupal/drupal/modules/simpletest/drupal_web_test_case.php,v
retrieving revision 1.7
diff -u -r1.7 drupal_web_test_case.php
--- modules/simpletest/drupal_web_test_case.php	20 May 2008 20:28:05 -0000	1.7
+++ modules/simpletest/drupal_web_test_case.php	20 May 2008 21:21:55 -0000
@@ -1055,4 +1055,51 @@
     $match = is_array($code) ? in_array($curl_code, $code) : $curl_code == $code;
     return $this->assertTrue($match, $message ? $message : t('HTTP response expected !code, actual !curl_code', array('!code' => $code, '!curl_code' => $curl_code)), t('Browser'));
   }
+
+  /**
+   * Assert that errors were found. If an array of messages is specified
+   * then assert that each of the error messages is found.
+   * 
+   * @return boolean Assertion result.
+   */
+  function assertDrupalErrors(array $messages = array()) {
+    if ($this->parse()) {
+      $found = array();
+      $errors = $this->elements->xpath("//div[@class='messages error']");
+
+      if (!empty($errors)) {
+        $errors = $errors[0];
+
+        // If ul is present then multiple errors displayed.
+        if (isset($errors->ul)) {
+          foreach ($errors->ul->li as $li) {
+            $found[] = trim((string) $li);
+          }
+        }
+        else {
+          $found[] = trim((string) $errors);
+        }
+      }
+      
+      // If no messages specified then just asssert that some errors are displayed.
+      if (count($messages) == 0) {
+        return $this->assertTrue(count($found) > 0, t('Found error message(s).'));
+      }
+      return $this->assertTrue(count(array_diff($messages, $found)) == 0, t('Found @count error message(s).', array('@count' => count($messages))));
+    }
+    return FALSE;
+  }
+
+  /**
+   * Assert that no errors were found.
+   * 
+   * @return boolean Assertion result.
+   */
+  function assertNoDrupalErrors() {
+    if ($this->parse()) {
+      $errors = $this->elements->xpath("//div[@class='messages error']");
+      return $this->assertTrue(empty($errors), t('No errors found.'));
+    }
+    return FALSE;
+  }
 }
