# RunTestsRequest

Specifies information about the Apex code to be tested. RunTestsRequest is part of [CompileAndTestRequest](/docs/platform/api/guide/sforce-api-calls-compileandtest-request.md), which is the request passed to the [`compileAndTest()`](/docs/platform/api/guide/sforce-api-calls-compileandtest.md) call. This object is also passed to the Tooling SOAP API call `runTests()`. You can specify the same or different classes to be tested and compiled. Since triggers cannot be tested directly, they are not included in this object. Instead, you must specify a class that calls the trigger.

If the request is sent to a production organization, this request is ignored and all unit tests defined for your organization are run.

The RunTestsRequest object has the following properties:

<sfdocstbl><table>

<col>
</col>
<col>
</col>
<col>
</col>
<thead>
  <tr>
    <th>
      Name
    </th>
    <th>
      Type
    </th>
    <th>
      Description
    </th>
  </tr>
</thead>
<tbody>
  <tr>
    <td>
      <code>allTests</code>
    </td>
    <td>
      boolean
    </td>
    <td>
      If
      <code>allTests</code>
      is true, all unit tests defined for your organization are run.
    </td>
  </tr>
  <tr>
    <td>
      <code>classes</code>
    </td>
    <td>
      string[]
    </td>
    <td>
      An array of one or more objects.
    </td>
  </tr>
  <tr>
    <td>
      <code>namespace</code>
    </td>
    <td>
      string
    </td>
    <td>
      If specified, the namespace that contains the unit tests to be run. Do not use this property if you specify allTests as true. Also, if you execute
      <code>compileAndTest()</code>
      in a production organization, this property is ignored, and all unit tests defined for the organization are run.
    </td>
  </tr>
  <tr>
    <td>
      <code>maxFailedTests</code>
    </td>
    <td>
      int
    </td>
    <td>
      A mandatory parameter for the Tooling SOAP API call
      <code>runTests()</code>
      . To allow all tests in a run to execute, set
      <code>maxFailedTests</code>
      to
      <code>-1</code>
      . To stop the test run from executing new tests after a given number of tests fail, set
      <code>maxFailedTests</code>
      to an integer value from
      <code>0</code>
      to
      <code>1,000,000</code>
      . This integer value sets the maximum allowable test failures. A value of
      <code>0</code>
      causes the test run to stop if any failure occurs. A value of
      <code>1</code>
      causes the test run to stop on the second failure, and so on.
    </td>
  </tr>
  <tr>
    <td>
      <code>packages</code>
    </td>
    <td>
      string[]
    </td>
    <td>
      Do not use after version 10.0. For earlier, unsupported releases, the content of the package to be tested.
    </td>
  </tr>
  <tr>
    <td>
      <code>skipCodeCoverage</code>
    </td>
    <td>
      boolean
    </td>
    <td>
      Indicates whether to opt out of collecting code coverage information during Apex test runs. Available in API version 43.0 and later.
    </td>
  </tr>
  <tr>
    <td>
      <code>tests</code>
    </td>
    <td>
      <a href="#testsnode">TestsNode</a>
      []
    </td>
    <td>
      <p>
        A mandatory parameter for the Tooling SOAP API call
        <code>runTests()</code>
        . Specifies individual test methods in an Apex test class.
      </p>
      <p>
        To specify classes or suites instead of a TestsNode[], set
        <code>tests</code>
        to
        <code>null</code>
        .
      </p>
      <p>
        Although this property accepts an array, the array can contain only one entry.
      </p>
    </td>
  </tr>
</tbody>
</table></sfdocstbl>

## TestsNode

Specifies individual test methods in an Apex test class.

| Name          | Type     | Description                                                                                                                                                                                               | Supported Methods                                                                                 |
| ------------- | -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------- |
| `classId`     | string   | The ID of the Apex class that contains the test methods you want to run. `classId` or `className` is required.                                                                                            | Values are `getClassId()`, or `setClassId(new String "<your class ID>")`.                         |
| `className`   | string   | The name of the Apex class that contains the test methods you want to run. To run tests from a managed package, include the package’s namespace using dot notation. `classId` or `className` is required. | Values are `getClassName()`, or `setClassName(new String "YourClassName")`.                       |
| `testMethods` | string[] | The test methods you want to run. Required.                                                                                                                                                               | Values are `getTestMethods()`, or `setTestMethods(new String[] {"testMethod1", "testMethod2"}))`. |
