XML checkpoints in TestComplete check the contents of a specified XML document by comparing it with the baseline copy stored in your project as an XMLCheckpoint element.
The XML checkpoint takes only one parameter - the source of XML data to be checked. This parameter can be one of the following:
-
The fully qualified name or URL of the desired XML document (it lets you compare the stored data with any XML file).
-
The
IXMLDOMDocument
object (it lets you compare the stored data with any XML document). -
An
XMLCheckpoint
object (it lets you compare the stored data with data of another XMLCheckpoint element). -
A
WebService
object (this functionality is used to create web service checkpoints).
If you want to re-use an XML checkpoint in your test, for example, to check multiple XML documents against the same baseline XML document, you can replace the hard-coded XML source with a parameter that obtains the desired XML document before the checkpoint is called. In other words, you may want to parameterize your XML checkpoint.
The image below demonstrates two XML checkpoints. One of them verifies a hard-coded XML document, the other one verifies an XML document whose source is specified in the param1 keyword test parameter.
The sections below describe how to parameterize your XML checkpoints.
In keyword tests
-
Create a parameter that will pass the needed value to the checkpoint. It can be:
-
A test parameter. You create it on the Parameters page of your test.
-
A keyword test variable. You create it on the Variables page of your test.
-
A project or project suite variable. You can create them on the Variables page of your project or project suite respectively.
For example, the image below shows the Param1 parameter of a keyword test:
-
-
In your keyword test, replace the hard-coded value of the checkpoint operation with the created parameter or variable:
-
Assign the needed value to the created parameter or variable:
-
If you use a test parameter, set its value when you run your test:
-
If you run it as part of the project’s test items sequence, set the test parameter on the Test Items page of your project:
-
If you run your test from another test, set the parameter value when calling your test.
-
-
To set a variable value, you can use the Set Variable Value operation.
-
-
Run the test with the needed parameter value assigned.
In scripts
-
Define a parameter or variable that will pass the needed value to the checkpoint. It can be:
-
A script routine parameter.
-
A script variable.
For example, the code snippet below shows how to declare the Param1 parameter of a script routine:
JavaScript, JScript
function ValidateXMLFile(Param1)
{
…
}Python
def ValidateXMLFile(Param1):
…VBScript
Sub ValidateXMLFile(Param1)
…
End SubDelphiScript
procedure ValidateXMLFile(Param1);
begin
…
end;C++Script, C#Script
function ValidateXMLFile(Param1)
{
…
} -
-
Replace the hard-coded parameter of the
XML.XML_Checkpoint_Name.Check
method with the created variable or parameter:JavaScript, JScript
function ValidateXMLFile(Param1)
{
…
// Validate the xml file
XML.XmlCheckpoint1.Check(Param1);
…
}Python
def ValidateXMLFile(Param1):
…
# Validate the xml file
XML.XmlCheckpoint1.Check(Param1)
…VBScript
Sub ValidateXMLFile(Param1)
…
' Validate the xml file
Call XML.XmlCheckpoint1.Check(Param1)
…
End SubDelphiScript
procedure ValidateXMLFile(Param1);
begin
…
// Validate the xml file
XML.XmlCheckpoint1.Check(Param1);
…
end;C++Script, C#Script
function ValidateXMLFile(Param1)
{
…
// Validate the xml file
XML["XmlCheckpoint1"]["Check"](Param1);
…
} -
Assign the needed value to the parameter or variable:
-
If you use a script parameter, you set the parameter value when you call the script, either from another script routine or as the project’s test item.
The image below shows how to set the parameter value when running the script routine as a project’s test item:
-
If you use a variable, set its value in the script before the script executes the checkpoint.
-
-
Run the script with the needed parameter value assigned.
See Also
XML Checkpoints
XML Checkpoints
XML Checkpoint Operation
Check Method
Parameterizing Tests