The behavior of this method depends on whether the update feature is enabled and AllowedDifference is specified.
Check method performs a byte-by-byte comparison of the specified Stores item and an external file. If the files are identical, the method returns True. If the files differ, it returns False.
During the comparison, a special value that indicates the difference between the two files is calculated. After that, this value is compared with the value of the AllowedDifference parameter. If the calculated value equals zero or AllowedDifference, the compared files are considered identical. See How File Verification Works for a detailed description and examples.
|Note:||Instead of the
Call Files.MyFile_txt.Check("D:\MyDocuments\MyFile.txt", 100)
However, if the update feature is enabled (that is, if both the global Update files option and the stored file’s Update option are checked), the method updates the specified stored file during the script execution. In this case, the
Check method replaces the stored file with the file specified as a parameter of the method, posts a message reporting that the file was updated to the test log and always returns True.
|FileObj||An expression, variable or parameter that specifies a reference to a File object|
|AllowedDifference||[in]||Optional||Integer||Default value: 0|
The method is applied to the following object:
The method has the following parameters:
Specifies the fully-qualified name of the file to be compared.
This parameter is used during the comparison with permissible variations. It specifies the reference value of the allowed difference between the files in bytes (0 means that the files are physically identical). The
Check method calculates the value of the actual difference between the files and compares it with the value passed as AllowedDifference. If these values coincide, the method assumes that the files are identical. Otherwise, the method fails, TestComplete posts an error message to the test log, and the Details panel displays the actual value of the difference. You can use this value in future comparisons.
|Do not obtain the value of the difference every time when you are going to perform a file comparison. You should calculate the difference once and then use this value in future comparisons. Otherwise, if you calculate the value of the difference right before performing a comparison and then use it in the
In comparison mode, if the comparison procedure reports that the files are identical, the method returns True and posts a checkpoint message () to the test log. Otherwise, the method returns False and posts an error message () and a checkpoint message to the test log.
In update mode, the method always returns True.
Check method returns False, TestComplete posts an error message and a checkpoint message to the test log. The Details panel contains the total number of differences between the Stores item and the specified file. To obtain detailed comparison results, click the Details link that is shown in the Link column of the test log. TestComplete opens the File Comparison Result panel that shows differences between the baseline and compared files. For more information on this, see Analyzing File Verification Results.
If the method uses a third-party Diff utility for file comparison (the utility and its launch parameters are specified by the Files diff utility options) and the compared files are not equal, the method also posts an informative message to the test log. The message holds a link to the file comparison report generated by the utility. To view the report, click the Details link in the Link column of this message.
By default, if the
Check method cannot find or access the file to be compared, or the file does not match its baseline copy, the method will wait for the file to become accessible and for the comparison to complete successfully for the period the Tools > Current Project Properties > Playback > Auto-wait timeout setting specifies. If the method fails to access the file, or if the file does not match its baseline copy within this period, the comparison will fail.
The following code snippet demonstrates how you can compare a stored item (a baseline copy) with an actual file.
Log.Warning("List of orders was changed");
if not Files.OrdersList_old.Check("C:\\Work\\OrdersList.txt"): Log.Warning("List of orders was changed")
If Not Files.OrdersList_old.Check("C:\Work\OrdersList.txt") Then
Log.Warning("List of orders was changed")
if not Files.OrdersList_old.Check('C:\Work\OrdersList.txt') then
Log.Warning('List of orders was changed');
Log["Warning"]("List of orders was changed");