---
schema_version: "1"
id: 00c9ebde333a3ead06288ee94fc7740ec4d3f81d96c81750105c1e00b3f307df
title: "Test Procedures: Integration Procedures for Unit Testing"
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_test_proceduresintegration_procedures_for_unit_testing_55410.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_test_proceduresintegration_procedures_for_unit_testing_55410.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: fbce4e19f6eb8a4987556280c45f9390f2f2b560b272a0d62dd11176a599fbd2
description: An Integration Procedure that performs a unit test is a Test Procedure. You can use a Test Procedure to unit test almost anything an Integration Procedure can invoke, such as an Omnistudio Data Mapper, a Calculation Matrix, an Apex class, or another Integration Procedure.
products:
  - Omnistudio
release: "264"
---
# Test Procedures: Integration Procedures for Unit Testing

An Integration Procedure that performs a unit test is a _Test Procedure_. You can use a Test Procedure to unit test almost anything an Integration Procedure can invoke, such as an Omnistudio Data Mapper, a Calculation Matrix, an Apex class, or another Integration Procedure.

Using Test Procedures and the test framework, you can:

- Provide sample input to the entity being tested using a [Set Values Action for Integration Procedures](https://help.salesforce.com/s/articleView?id=xcloud.os_set_values_for_integration_procedures_50310.htm&release=264.0.0&type=5 "The Set Values action sets values in the data JSON of an Integration Procedure using literal values, merge fields, or formulas.") component.
- Mock responses of specific steps if the entity being tested is an Integration Procedure.
- Compare expected and actual results using an [Assert Action for Integration Procedures](https://help.salesforce.com/s/articleView?id=xcloud.os_assert_action_for_integration_procedures_50585.htm&release=264.0.0&type=5 "The Assert Action compares the expected and actual results of a Test Procedure using an expression that evaluates to true or false. You can use environment variables in the Assert Conditional Formula to test performance.") component.
- Use IDX Workbench to [run Test Procedures](https://help.salesforce.com/s/articleView?id=xcloud.os_run_test_procedures.htm&type=5&language=en_US).

After a Test Procedure finishes, its transaction is rolled back. This lets you run tests that create sObjects without affecting the database.

How you organize your Test Procedures is up to you. For example, you can test the same Data Mapper multiple times using different inputs, or you can test several different Data Mappers using the same Test Procedure.

## When to Mock Integration Procedure Components

When you use a Test Procedure to test another Integration Procedure, you can simulate, or mock, the responses of some of the components in the testing Integration Procedure or the Integration Procedure being tested. For example, you can mock a component that would normally retrieve a credit score, using a hard-coded score for testing. This has no effect on how the Integration Procedure normally runs when it isn't being tested.

To mock a component that returns a single value, scroll to the bottom of the Procedure Configuration and specify a Key/Value pair under Mock Responses Map. The Key must be the Name of a component, and the Value can be literal text or a merge field.

To mock a component with a more complex response, go to the Procedure Configuration and click **Edit as JSON**, then edit the `mockResponseMap` node. For example, the following JSON code mocks a Set Values component named `IfOtherState` that sets a `DefaultSalesTax` value:

```
"mockResponseMap": {
    "IfOtherState": {
        "DefaultSalesTax": 0.06
    }
}
```

The following component types must be mocked in the testing Integration Procedure or the Integration Procedure being tested. Mocking other component types is permitted but not required.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col>
          <col>
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d8384e136">
              <p style="margin-bottom:0;">Component</p>
            </th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d8384e142">
              <p style="margin-bottom:0;">Reason for Mocking</p>
            </th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Component" class="slds-cell-wrap" style="vertical-align:top;" headers="d8384e136 ">
              <p style="margin-bottom:0;">
                <a href="https://help.salesforce.com/s/articleView?id=xcloud.os_docusign_envelope_action_for_integration_procedures_52043.htm&amp;release=264.0.0&amp;type=5" title="The Docusign Envelope Action emails a set of documents for signing.">Docusign Envelope Action for Integration Procedures</a>
              </p>
            </td>

            <td data-label="Reason for Mocking" class="slds-cell-wrap" style="vertical-align:top;" headers="d8384e142 ">
              <p style="margin-bottom:0;">The response to the delivered email isn't available.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Component" class="slds-cell-wrap" style="vertical-align:top;" headers="d8384e136 ">
              <p style="margin-bottom:0;">
                <a href="https://help.salesforce.com/s/articleView?id=xcloud.os_email_action_for_integration_procedures_52105.htm&amp;release=264.0.0&amp;type=5" title="An Email Action sends the specified email. You can either specify all the email field values or use a Salesforce email template.">Email Action for Integration Procedures</a>
              </p>
            </td>

            <td data-label="Reason for Mocking" class="slds-cell-wrap" style="vertical-align:top;" headers="d8384e142 ">
              <p style="margin-bottom:0;">The response to the delivered email isn't available.</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="Component" class="slds-cell-wrap" style="vertical-align:top;" headers="d8384e136 ">
              <p style="margin-bottom:0;">
                <a href="https://help.salesforce.com/s/articleView?id=xcloud.os_http_action_for_integration_procedures_53002.htm&amp;release=264.0.0&amp;type=5" title="The HTTP Action executes a REST call and returns its results to the Integration Procedure. The HTTP Action in Integration Procedures supports only getBody() for returning the response. Use Apex directly via a Remote Action to handle binary responses.">HTTP Action for Integration Procedures</a>
              </p>
            </td>

            <td data-label="Reason for Mocking" class="slds-cell-wrap" style="vertical-align:top;" headers="d8384e142 ">
              <p style="margin-bottom:0;">Salesforce has specific requirements for&nbsp;<a href="https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_restful_http_testing_httpcalloutmock.htm" target="_blank">testing HTTP callouts</a>.</p>
            </td>

          </tr>
        </tbody>
      </table>

## HTTP Callouts in Called Apex Classes

If a Test Procedure or an Integration Procedure being tested includes a Remote Action, and the Apex class the Remote Action invokes includes an HTTP callout, then you must ensure that the HTTP callout isn't part of the test. To do this, edit the Apex class and enclose the HTTP callout in an `if (IntegrationProcedureService.isTest == false)` statement, for example:

```
if (IntegrationProcedureService.isTest == false) {
    HttpRequest request = new HttpRequest();
    request.setMethod('GET');
    request.setEndpoint('http://example.com');
        
    Http httpCall = new Http();
    HttpResponse response = httpCall.send(request);
}
```

- **[Workflow for Test Procedure Example](https://help.salesforce.com/s/articleView?id=xcloud.os_workflow_for_test_procedure_example_55479.htm&release=264.0.0&type=5)**  
    A Test Procedure tests a calculation performed by another Integration Procedure.