List Compare API

Introduction

This API compares values of 2 lists of an identical structure. It can compare and report on selected columns or all columns. Lists can be compared row by row, if both lists have the same row order, or alternatively the API can match list rows based on values in defined columns prior to making the comparison.

Drag a List Compare API from the API palette into your Test Case:

Update the parameters as follows:

  • List1: The name of the first list to be compared
  • List2: The name of the second lists to be compared
  • Match Columns: If you want to match list rows based on values in defined columns, enter the column name(s) here (use a comma-separated list for multiple columns). This is useful for comparing lists which may not be in the same order. Alternatively, to match on Row Number, leave this parameter blank.
  • Compare Columns: Comma-separated list of the names of columns to be compared and reported on. To compare and report on all columns, leave this blank
  • Ignore Columns: Comma-separated list of the names of columns to be skipped
  • On Differences: The reporting action to be performed if a difference occurs between the values being compared
  • On Unmatched List 1 rows: The reporting action to be performed when a value in the first list does not have a corresponding value in the second. This will also occur when Match Columns have been specified but no result found. It will also occur when the comparison is done on Row Number and there is an extra row in the first list
  • On Unmatched List 2 rows: The reporting action to be performed when a value in the second list does not have a corresponding value in the first
  • Case Insensitive: Tick this checkbox to ignore case when comparing values

Then save the Test Case.

List Compare Examples

Below are some examples of how to use the List Compare API to satisfy different use cases.

The Test Case below compares 2 lists of leads containing Name and OwnerId. Each scenario queries Salesforce for an actual results list and compares it with the list of expected values stored in an Excel sheet. 4 different scenarios will be described.

Scenario 1: Comparing 2 columns across lists with the same row order

 

This scenario compares Name and OwnerId in Row 1 of List 1 with Name and OwnerId in Row 1 of List 2. It continues through all rows and reports any differences.

This is defined in the parameters as follows:

Note that Match Column is blank, meaning that the match will be based on Row Number alone. Compare Columns and Ignore Columns are also blank, meaning that all columns will be compared and reported on.

If there are extra items in either list, these will be reported under Unmatched List Rows for List 1 or 2 respectively.

Note the two failures occurring at Row 4, since the Name and OwnerId values are different between List 1 Row 4 and List 2 Row 4. Note also the warning for the unmatched row in List 2.

Scenario 2: Comparing 1 column across lists with the same row order

 

This scenario compares OwnerId in Row 1 of List 1 with OwnerId in Row 1 of List 2. It continues until all rows in lists are covered, and reports any differences.

This is defined in the parameters as follows:

      

Note that, as in Scenario 1, Match Column is blank, meaning that the match will be based on Row Number alone. Unlike Scenario 1, Compare Column has been specified as ‘OwnerId’, meaning that only this column will be compared and reported on.

Note that, unlike Scenario 1, only a single failure occurs at Row 4, since the OwnerId value is different between the lists but the Name value has not been compared.

Scenario 3: Ignoring 1 column and comparing the rest across 2 lists with the same row order

This scenario compares OwnerId in Row 1 of List 1 with OwnerId in Row 1 of List 2. It continues until all rows in lists are covered, and reports any differences.

This is effectively the same as scenario 2, but uses the Ignore Columns parameter instead of the Compare Columns parameter:

The results are the same as for Scenario 2:

Scenario 4: Comparing all columns across 2 lists and matching rows using a specific value

 

This scenario picks the entire row (Name and OwnerId) in Row 1 of List 1 and selects the corresponding row in List 2 by matching on the OwnerId value.

If no match is found, the row is reported as an Unmatched List 1 row. If a match is found, it compares both Name and OwnerId values and reports on any differences. It continues this for all List 1 rows and then runs the same process for all List 2 rows.

      

Note that Match Column is set to ‘Name’, meaning that the match will be based on the values in the ‘Name’ column. The Compare Column is also blank, meaning that all columns will be compared and reported on.

Note that a failure occurs at List 1 Row 3 since the OwnerId values are different between the lists. In addition, there are three unmatched row warnings: Row 4 in List 1 and Row 4 and Row 8 in List 2.

Note that using Match Columns in this scenario has generated more unmatched row warnings than using Row Number. In this example, the Name value of Row 4 is slightly different between Lists 1 and 2, leading ‘Shelly Brownell’ and ‘Shelly Brownell (Diff)’ being treated as two unmatched rows, rather than a column difference.

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

Leave A Comment