You are here:
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 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 component.
-
Use IDX Workbench to run Test Procedures.
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.
Component |
Reason for Mocking |
|---|---|
The response to the delivered email isn't available. |
|
The response to the delivered email isn't available. |
|
Salesforce has specific requirements for testing HTTP callouts. |
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
A Test Procedure tests a calculation performed by another Integration Procedure.

