In TestComplete, file checkpoints verify the actual contents of specified files comparing them with baseline files stored in the project’s Stores | Files collection.
File checkpoints in TestComplete take two parameters:
-
The name (with the full path) of the file you want to verify.
-
The allowed difference value (in bytes).
File checkpoints you create by using the File Checkpoint wizard use hard-coded values to indicate the file to verify and the allowed difference.
You may want to parameterize your file checkpoints in your tests, that is, to replace file checkpoints’ hard-coded values with variable values.
For example, if a name of the file you want to verify changes between test runs, you can replace the checkpoint’s hard-coded file name with a parameter that obtains the required file name before each test run.
This topic provides information on how to parameterize file checkpoints:
In Keyword Tests
To parameterize your file checkpoints in keyword tests, in the Operation Parameters dialog of the File Checkpoint operation, replace the operation’s hard-coded values with keyword test parameters or with keyword test, project or project suite variables containing desired data.
The image below demonstrates two file checkpoints. One of them verifies a file specified by its hard-coded name, the other verifies a file whose path is stored in the keyword test Param1 parameter:
In Scripts
To parameterize your file checkpoints in scripts, replace the hard-coded parameters of the Files.FileCheckpointName.Check
method with script routine parameters or with script, project or project suite variables.
The following code example demonstrates two file checkpoints. One of them verifies the contents of a file specified by its hard-coded path, the other one verifies the contents of a file whose path is stored in the script routine parameter param1
:
JavaScript, JScript
function Test(param1)
{
…
Files.new_test("C:\\Work\\File Checkpoints\\new_test.txt");
…
Files.new_test(param1);
…
}
Python
def Test(param1):
...
Files.new_test("C:\\Work\\File Checkpoints\\new_test.txt")
...
Files.new_test(param1)
...
VBScript
Sub Test(param1)
…
Files.new_test("C:\Work\File Checkpoints\new_test.txt")
…
Files.new_test(param1)
…
End Sub
DelphiScript
procedure Test(param1);
begin
…
Files.new_test('C:\Work\File Checkpoints\new_test.txt');
…
Files.new_test(param1);
…
end;
C++Script, C#Script
function Test(param1)
{
…
Files["new_test"]("C:\\Work\\File Checkpoints\\new_test.txt");
…
Files["new_test"](param1);
…
}
See Also
File Checkpoints
About File Checkpoints
Creating File Checkpoints
Parameterizing Keyword Tests
Parameterizing Script Routines