Compare Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

Use the Compare method to compare the values stored in the DBTable project element that corresponds to the DBTableObj object with the values that are stored in the database that is specified by the element’s properties.

Using the Compare method you can also update the data stored in the DBTable element. TestComplete does this if the Update DBTable elements option is enabled. See also Modifying DBTable Elements.

Declaration

DBTableObj.Compare(ReportDifference, MessageType)

DBTableObj An expression, variable or parameter that specifies a reference to a DBTable object
ReportDifference [in]    Optional    Boolean Default value: True   
MessageType [in]    Optional    Variant Default value: lmWarning   
Result Boolean

Applies To

The method is applied to the following object:

Parameters

The method has the following parameters:

ReportDifference

Specifies whether the method posts a warning message about each difference to the test log.

MessageType

The type of message to be posted to the test log in case the comparison fails and ReportDifference is True. Possible values:

Constant Value Description
lmNone 0 Do not post any message.
lmMessage 1 Post an informative message.
lmWarning 2 Post a warning message.
lmError 3 Post an error message.

Result Value

True, if the comparison is successful and False otherwise.

Remarks

The Compare method returns True or False and also posts a message to the test log indicating the comparison result. By default, the method logs each difference found during the comparison. If there are several differences, the method will post several log messages. To specify the message type - warning, error or informational message - use the MessageType parameter. To disable failure logging, set the method’s ReportDifference parameter to False.

For sample code and information about comparison specifics, see About Database Checkpoints.

Example

The code below specifies comparison parameters and then compares stored data with data from a database.

JavaScript, JScript

function CompareDBTables()
{
  // Specifies a DB Table element
  var DBTab = DBTables.Table1;
  
  // Specifies comparison parameters
  var ReportDif = True;
  var MessType = lmError;
  // Compares the DB Table element with data stored in a database
  DBTab.Compare(ReportDif, MessType);
}

Python

def CompareDBTables():
  # Specifies a DB Table element
  DBTab = DBTables.Table1
  # Specifies comparison parameters
  ReportDif = True
  MessType = lmError
  # Compares the DB Table element with data stored in a database
  DBTab.Compare(ReportDif, MessType)

VBScript

Sub CompareDBTables
  
  ' Specifies a DB Table element
  Set DBTab = DBTables.Table1
  
  ' Specifies comparison parameters
  ReportDif = True
  MessType = lmError
  ' Compares the DB Table element with data stored in a database
  Call DBTab.Compare(ReportDif, MessType)
   
End Sub

DelphiScript

function CompareDBTables();
var DBTab, ReportDif, MessType;
begin

  // Specifies a DB Table element
  DBTab := DBTables.Table1;
  
  // Specifies comparison parameters
  ReportDif := True;
  MessType := lmError;
  // Compares the DB Table element with data stored in a database
  DBTab.Compare(ReportDif, MessType);

end;

C++Script, C#Script

function CompareDBTables()
{
  // Specifies a DB Table element
  var DBTab = DBTables["Table1"];
  
  // Specifies comparison parameters
  var ReportDif = True;
  var MessType = lmError;
  // Compares the DB Table element with data stored in a database
  DBTab["Compare"](ReportDif, MessType);
}

See Also

About Database Checkpoints
Modifying DBTable Elements

Highlight search results