diff --git a/includes/xmlrpcs.inc b/includes/xmlrpcs.inc
index 70c7cda..22ff469 100644
--- a/includes/xmlrpcs.inc
+++ b/includes/xmlrpcs.inc
@@ -79,6 +79,18 @@ function xmlrpc_server($callbacks) {
   xmlrpc_server_set($xmlrpc_server);
   $result = xmlrpc_server_call($xmlrpc_server, $xmlrpc_server->message->methodname, $xmlrpc_server->message->params);
 
+  // If the XML-RPC call was made during a test then store the method,
+  // parameters, and result so the test can run assertions against them.
+  $test_info = &$GLOBALS['drupal_test_info'];
+  if (!empty($GLOBALS['drupal_test_info']['in_child_site'])) {
+    $call = array(
+      'method' => $xmlrpc_server->message->methodname,
+      'parameters' => $xmlrpc_server->message->params,
+      'result' => $result,
+    );
+    trigger_error(serialize($call), E_USER_WARNING);
+  }
+
   if (is_object($result) && !empty($result->is_error)) {
     xmlrpc_server_error($result);
   }
diff --git a/modules/simpletest/drupal_web_test_case.php b/modules/simpletest/drupal_web_test_case.php
index 5c39cfc..3ccb5e6 100644
--- a/modules/simpletest/drupal_web_test_case.php
+++ b/modules/simpletest/drupal_web_test_case.php
@@ -74,6 +74,13 @@ abstract class DrupalTestCase {
   protected $skipClasses = array(__CLASS__ => TRUE);
 
   /**
+   * List of XML-RPC calls that have been executed during the test.
+   *
+   * @var array
+   */
+  protected $xmlrpcCalls = array();
+
+  /**
    * Constructor for DrupalTestCase.
    *
    * @param $test_id
@@ -406,6 +413,10 @@ abstract class DrupalTestCase {
       // set the message to a status of 'debug'.
       return $this->assert('debug', $message, 'Debug', $caller);
     }
+    else if ($group == 'User warning') {
+      $this->xmlrpcCalls[] = unserialize($message);
+      return FALSE;
+    }
 
     return $this->assert('exception', $message, $group, $caller);
   }
@@ -555,6 +566,40 @@ abstract class DrupalTestCase {
   }
 
   /**
+   * Assert that the most recent XML-RPC call matches the parameters.
+   *
+   * @param $method
+   *   XML-RPC method string.
+   * @param $parameters
+   *   (Optional) The parameters passed in the XML-RPC call.
+   * @param $result
+   *   (Optional) The result returned in the XML-RPC call.
+   * @param $message
+   *   (Optional) The message to display along with the assertion.
+   * @param $group
+   *   (Optional) The type of assertion - examples are "Browser", "PHP".
+   * @return
+   *   TRUE if the assertion succeeded, FALSE otherwise.
+   */
+  protected function assertXmlrpc($method, $parameters = array(), $result = NULL, $message = '', $group = 'Other') {
+    if (!$message) {
+      $message = 'XML-RPC call found {' . $method . ', ' . print_r($parameters, TRUE) . ', ' . print_r($result, TRUE) . '}';
+    }
+    $call = end($this->xmlrpcCalls);
+    return $this->assertTrue($method == $call['method'] && $parameters == $call['parameters'] && (!$result || $result == $call['result']), $message, $group);
+  }
+
+  /**
+   * Get a list of all the XML-RPC calls made during the test run.
+   *
+   * @return
+   *   List of XML-RPC calls made during the test run.
+   */
+  protected function getXmlrpcCalls() {
+    return $this->xmlrpcCalls;
+  }
+
+  /**
    * Generates a random string containing letters and numbers.
    *
    * The string will always start with a letter. The letters may be upper or
@@ -656,6 +701,9 @@ class DrupalUnitTestCase extends DrupalTestCase {
   protected function setUp() {
     global $conf;
 
+    // Ensure the list of calls is always cleared.
+    $this->xmlrpcCalls = array();
+
     // Store necessary current values before switching to the test environment.
     $this->originalFileDirectory = variable_get('file_public_path', conf_path() . '/files');
 
@@ -1268,6 +1316,9 @@ class DrupalWebTestCase extends DrupalTestCase {
     $this->originalShutdownCallbacks = $callbacks;
     $callbacks = array();
 
+    // Ensure the list of calls is always cleared.
+    $this->xmlrpcCalls = array();
+
     // Create test directory ahead of installation so fatal errors and debug
     // information can be logged during installation process.
     // Use temporary files directory with the same prefix as the database.
diff --git a/modules/simpletest/simpletest.test b/modules/simpletest/simpletest.test
index e5b6042..2fdae70 100644
--- a/modules/simpletest/simpletest.test
+++ b/modules/simpletest/simpletest.test
@@ -133,7 +133,6 @@ class SimpleTestFunctionalTest extends DrupalWebTestCase {
       $this->stubTest();
     }
     else {
-
       // Run twice so test_ids can be accumulated.
       for ($i = 0; $i < 2; $i++) {
         // Run this test from web interface.
@@ -461,6 +460,56 @@ class SimpleTestMailCaptureTestCase extends DrupalWebTestCase {
   }
 }
 
+class SimpleTestXMLRPCCaptureTestCase extends DrupalWebTestCase {
+
+  /**
+   * Implement getInfo().
+   */
+  public static function getInfo() {
+    return array(
+      'name' => 'SimpleTest XML-RPC capturing',
+      'description' => 'Test the SimpleTest XML-RPC capturing logic, the assertXMLRPC() assertion and the drupalGetXmlrpcCalls() function.',
+      'group' => 'SimpleTest',
+    );
+  }
+
+  protected function testXMLRPC() {
+    // Call system.methodHelp for system.methodSignature and check the result.
+    $help = 'Returns an array describing the return type and required parameters of a method.';
+    $result = xmlrpc(url('', array('absolute' => TRUE)) . '/xmlrpc.php', 'system.methodHelp', 'system.methodSignature');
+    $this->assertEqual($help, $result, 'XML-RPC result was correct for system.methodHelp');
+    $this->assertXmlrpc('system.methodHelp', array('system.methodSignature'));
+    $this->assertXmlrpc('system.methodHelp', array('system.methodSignature'), $help);
+
+    // Call system.listMethods and confirm the result.
+    $methods = array(
+      'system.multicall',
+      'system.methodSignature',
+      'system.getCapabilities',
+      'system.listMethods',
+      'system.methodHelp',
+    );
+    $result = xmlrpc(url('', array('absolute' => TRUE)) . '/xmlrpc.php', 'system.listMethods');
+    $this->assertEqual($methods, $result, 'XML-RPC result was correct for system.listMethods');
+    $this->assertXmlrpc('system.listMethods');
+    $this->assertXmlrpc('system.listMethods', array(), $methods);
+
+    // Ensure that all the XML-RPC calls where properly stored.
+    $calls = $this->getXmlrpcCalls();
+    $this->assertEqual(2, count($calls), 'Two calls stored');
+    $this->assertEqual($calls[0], array(
+      'method' => 'system.methodHelp',
+      'parameters' => array('system.methodSignature'),
+      'result' => $help,
+    ), 'First call matches');
+    $this->assertEqual($calls[1], array(
+      'method' => 'system.listMethods',
+      'parameters' => array(),
+      'result' => $methods,
+    ), 'Second call matches');
+  }
+}
+
 /**
  * Test Folder creation
  */
