API Testing

Provar provides various APIs to assist in the rapid creation and maintenance of test data.

To learn more, use the following links to navigate to the relevant section:

These APIs can also be used to mass-create or update test data, working alongside a source such as an Excel spreadsheet. Refer to Read Data From Excel for more information.

Usage

To add an API Test Step, click on a row of test data in the Org Browser and drag it into your Test Case:

Test Steps will be added with the same Connection as the one selected in the Org Browser, but this can be overridden if wanted.

Note that Provar generally logs the Salesforce test data created during a Test Run. This can be controlled per Test Case, and is controlled by the ‘Enable Object Id Logging’ checkbox on the Salesforce Connect Test Step:

Provar can automatically delete data at the end of a Test Run if wanted. To enable this option, tick the checkbox ‘Auto Cleanup’. If the Test Case’s Connection user will not have privileges to perform the cleanup, specify an admin Connection in ‘Cleanup Connection Name’. This information will be written to the log file when the cleanup is performed.

SOQL Query

A SOQL Query Test Step is useful for asserting data or for searching for IDs for specific Salesforce records. Refer to Salesforce’s documentation for more information on SOQL.

To use this API, click and drag a row of data from the Org Browser into the Test Case, then select ‘Add a SOQL Query Step’. Make sure that the row of data chosen in the Org Browser corresponds to the Object you want to query (e.g. Opportunity).

Select which fields to return in the query:

Then click the ‘OK’ button.

This will automatically generate a simple SOQL statement:

This statement can be amended manually, e.g. to add a WHERE clause. Refer to the Org Browser if you are unsure of the API Name for any given field.

When this Test Step is executed, it will populate OpportunityRows, or whatever name is specified in the ‘Result List Name’ (see screenshot above). This can then be accessed in subsequent Test Steps. A period can be added after OpportunityRows to access a specific variable, e.g. OpportunityRows.Name.

Read/Assert

A Read/Assert Test Step is useful for validating or checking data at an API level.

To use this API, click and drag a row of data from the Org Browser into the Test Case, then select ‘Add an Object read/assert step’. Make sure that the row of data chosen in the Org Browser corresponds to the Object you want to read/assert (e.g. Opportunity).

In the form which follows, tick fields in the first column to read values and tick fields in the second column to create asserts.

Then click the ‘OK’ button.

This will automatically generate the following Test Step:

In this example, reads and asserts have both been added. To add or remove fields after the Test Step has been added, click the  icon at the top of the Test Step parameters.

Read results will be added to the Result Object OpportunityRead, or whatever name is specified in the ‘Result Object’ (see screenshot above). This can then be accessed in subsequent Test Steps. A period can be added after OpportunityRead to access a specific variable, e.g. OpportunityRead.StageName.

Asserts have been added as separate sections underneath, validating specific values for Name and Stage. If these are not passed during execution, the Test Step will fail.

Create

A Create Test Step is useful for creating records at the API level.

To use this API, click and drag a row of data from the Org Browser into the Test Case, then select ‘Add an Object create step’. Make sure that the row of data chosen in the Org Browser corresponds to the Object you want to create (e.g. Opportunity).

Select which fields to populate in the Test Step. Note that required fields are ticked automatically:

Then click the ‘OK’ button.

This will automatically generate the following Test Step:

Note that the fields to be populated are shown under the Fields section. Field values will be prefilled from the original data row copied from the Org Browser, if a value was supplied. These values can be overridden as wanted.

To add or remove fields after the Test Step has been added, click the  icon at the top of the Test Step parameters.

When this Test Step is executed, a new record will be created and the record ID added to the variable named in ‘Result Object Id’, e.g. OpportunityId.

Update

An Update Test Step is useful for amending record information at the API level.

To use this API, click and drag a row of data from the Org Browser into the Test Case, then select ‘Add an Object update step’. Make sure that the row of data chosen in the Org Browser corresponds to the Object you want to update (e.g. Opportunity).

Select which fields to populate in the Test Step. Note that Required fields are also identified:

This will automatically generate the following Test Step:

Make sure that ‘Object Id’ correctly identifies the record to be updated. Where applicable, it will be prepopulated based on the data row chosen from the Org Browser, but it should generally be updated to a variable storing the record ID, e.g. OpportunityId. Use the Value Picker to locate the correct variable (CTRL + spacebar). In this example, OpportunityId is populated through the preceding Create Test Step.

Note that the fields to be updated are shown under the Fields section in Test Step parameters. To add or remove fields after the Test Step has been added, click the  icon at the top of the Test Case.

Delete

Delete Test Step is used to delete a record at the API level.

To use this API, click and drag a row of data from the Org Browser into the Test Case, then select ‘Add an Object delete step’. Make sure that the row of data chosen in the Org Browser corresponds to the Object you want to update (e.g. Opportunity).

This will automatically generate the following Test Step:

Make sure that ‘Object Id’ correctly identifies the record to be updated. Where applicable, it will be prepopulated based on the data row chosen from the Org Browser, but it should generally be updated to a variable storing the record ID, e.g. OpportunityId. Use the Value Picker to locate the correct variable (CTRL + spacebar). In this example, OpportunityId is populated through the preceding Create Test Step.

2017-05-12T11:34:44+00:00

Leave A Comment