Compare Files Operation

Applies to TestComplete 14.70, last modified on April 22, 2021

Description

Use the Compare Files operation to compare two files or to update a file stored in the Stores | Files collection of your TestComplete project. The operation’s functioning mode is specified by the Update attribute of a stored file. By default, the operation compares two files. However, if both the Update files setting and the Update attribute are enabled, the operation updates the stored file.

The operation compares files byte by byte, and can perform strict comparison or compare files ignoring certain difference. For more information, see How File Verification Works.

When you add the operation to your test, TestComplete displays a dialog in which you specify the files to be compared, as well as comparison options.

Operation Result

In comparison mode, if the comparison procedure reports the files to be identical, the operation returns True.

Otherwise, the operation returns False and posts a message corresponding to the operation’s MessageType parameter to the log. If the operation uses a third-party Diff utility for file comparison (the utility and its launch parameters are specified by the Files diff utility options), the operation also posts an informative message to the test log. The message holds a link to the file comparison report generated by the utility.

In update mode, the operation always returns True and posts a checkpoint message () to the test log.

Scripting Analogue

The operation is an analogue of the Files.Compare scripting method.

Child Operations

The operation cannot have child operations.

Operation Parameters

The operation uses the following parameters:

File1 and File2

Specifies the names of the files to be compared or the name of the stored file and of the file that will replace it. To specify each file, you can either use the fully-qualified file name, or, if the file belongs to the Stores | Files collection of your project, use the name that the file has in this collection. To specify the name of a stored file, press the down arrow and select the desired item from the ensuing drop-down list. To specify the name of a file that is not stored in the Files collection, press the ellipsis button and specify the desired name in the ensuing Edit Parameter dialog.

If the operation works in update mode, then one of the file names must specify an element of the Files collection.

The file order is not important if the operation performs strict comparison or if the operation works in update mode. However, the file order is important if you compare files using the HashValue parameter (see below). The difference calculation algorithm takes into account which file is specified first and which file follows it. It will return a different value of the dissimilarity between two files if you change the file order. So, if you compare files with the HashValue parameter, you should specify them in the order in which you specified them to obtain the value of the allowed difference (see below).

HashValue

Integer. Specifies the allowed difference between files in bytes. The allowed difference of equal files is 0. When comparing files, the operation calculates the difference between them and compares it with the HashValue parameter. If the values are equal, the operation considers the files to be equal.

To obtain the value of the difference between two files, you can use the string that is posted to the Details panel of the test log if comparison fails.

ReportDifference

Boolean. Specifies whether the operation posts a message to the test log when comparison fails. If comparison fails, this string will contain information about the amount of bytes that are different in the compared files.

MessageType

Integer. Specifies the type of the message which the operation posts to the test log when comparison fails. MessageType can take on one of the following 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.

For information on specifying the MessageType parameter value, see Specifying Enumeration Values in Parameters.

To modify the operation’s parameters:

  1. Select the needed operation in your keyword test.

  2. Click the Value cell twice (not double-click) or select the cell and press F2. This will activate the in-place editor.

  3. Click the ellipsis button of the in-place editor. TestComplete will open the Operation Parameters dialog.

  4. In the dialog, specify the operation parameters. For detailed information on how to work with the dialog, see Specifying Operation Parameters.

  5. Click OK to close the dialog and apply changes.

  6. Press Enter to confirm the changes and close the in-place editor, or press Esc to close the editor discarding any changes.

Remarks

For information on file checkpoints and file comparison, see the topics of the File Checkpoints section.

See Also

Checkpoints Category
File Checkpoint Operation
About File Checkpoints
Specifying Operation Parameters
Checking Operation Result

Highlight search results