This topic explains how you can create a web service checkpoint to verify results of the needed web service method call.
|To work with Web service checkpoints, add a Web Service element to your project. This element should correspond to the web service under test. You need to create such elements for each web service under test.|
You can create web service checkpoints both during test recording and at design time. To help you set up web service checkpoints, TestComplete provides the Checkpoint Wizard.
Below are detailed instructions on using the wizard:
Select the Checkpoints category in the Operations panel of the Keyword Test editor.
Find the Web Service Checkpoint operation in the list and drag it to your test:
On the following pages of the wizard, specify the needed web service and its method to be called by the checkpoint:
Select the WebService project element that corresponds to the web service under test (you need to create such an element for each web service under test).
Choose the method of the web service to be called.
The next page shows the list of method parameters.
|Parameter Name||Specifies the parameter name (TestComplete reads this name from the web service’s WSDL document).|
|Parameter Type||Specifies the parameter type (TestComplete reads the type name from the web service’s WSDL document).|
|Parameter Value||Specifies the value that will be passed to the method.|
To specify a parameter of an ordinary type (string, numerical, boolean and so on), enter the desired value into the Parameter Value column.
To specify complex parameter values (that refer to objects), click the ellipsis button in the Parameter Value column and specify the parameter in the subsequent Complex Parameter dialog.
On the last page of the wizard, you specify the XMLCheckpoint project element that will store the expected response of the web service’s method:
Click Use a stored value, and then select the desired element from the Stores object name drop-down list.
Click Select the result value and save it to Stores.
Enter the name of the XMLCheckpoint element to be created in the Create a new Stores item box.
|Note:||This name will be used to address the element from scripts, so the name must be a valid identifier. To create a name that will match the rules of any scripting language supported by TestComplete, enter a name that starts with a letter and contains only letters, digits and underscore symbols.|
|If TestComplete fails to obtain a response from the web service (for instance, if the service is temporary unavailable), TestComplete generates the expected response using predefined values for XML document elements that correspond to the result value (or values). For instance, if the method returns an integer value, TestComplete generates the value of 0 for the element that holds the result value.
In that case, you need to replace these predefined values with expected values in the XMLCheckpoint element. Otherwise, comparison will make no sense.
You can also modify the expected response of the web service. Web services use the SOAP protocol that transmit data in XML format. The page includes an editor, which you can use to view and modify the response contents.
To add a new element, attribute or some other node to the XML document, select an item from the menu that is displayed at the top of the node’s tree. This menu contains the following submenus:
Element - Adds a new element to the document.
Attribute - Adds a new attribute to an element.
Text - Adds a text node (
#text) to the document.
Comment - Adds a comment (
<!-- Comment text -->) to the document.
CDATA - Adds a CDATA node to the document (
<![CDATA[ ... ]]>).
PI - Adds a processing instruction (
<?xml-stylesheet type="text/xsl" href="../../myTemplate.xsl"?>) or xml declaration nodes to the document (
Each of these submenus contains three items: Before, After and Child. They specify the position of the new node relative to the currently selected node. For instance, if the currently selected node corresponds to an element, then the Element | After menu item will insert a new element after the currently selected node. The Element | Child item will append a new element as a child of the currently selected element.
The Before, After and Child menu items can be disabled or enabled according to the context. If some menu item is disabled, this means that the appropriate node cannot be added to the document at the appropriate position. For instance, processing instructions, comments or CDATA nodes cannot be child nodes of attributes. So, if the currently selected node corresponds to an attribute, the PI | Child, Comment | Child and CDATA | Child menu items are disabled.
Each element has an appropriate icon:
Select the desired node’s name in the tree.
Click the node name or press F2. This will activate the in-place editor.
Enter a new name into the in-place editor. Press Enter to confirm the changes or Esc to cancel them.
Select the cell containing the desired node’s value.
Click the node name or press F2. This will activate an in-place editor.
Enter the desired value into the in-place editor. Use Ctrl+Enter to enter a line break.
To confirm changes, press Enter. To cancel changes, press Esc.
|Note:||An element’s node may have the or icon. The icon indicates that the element’s node has a child node (for instance, a
The icon indicates that the element does not have child nodes and the element’s value can be set in the Value column.
– or –
– or –
A node is copied along with its child nodes.
You can also delete the selected node by choosing Delete from the toolbar that is displayed above the tree.
If the selected node has child nodes, they are also deleted.
To undo or redo changes made to the XML data, use the Undo and Redo toolbar items that are displayed above the tree.
By default, TestComplete uses the UTF-8 encoding for the XML data. To change the encoding:
encodingattribute of the
Click Finish to close the wizard and complete the checkpoint creation.
TestComplete will automatically create (or update) the specified XMLCheckpoint element, and then add a checkpoint to your test.
If you add the checkpoint to the script code, then upon closing the wizard, TestComplete will generate script code that will call the method and check the result against data stored by the XMLCheckpoint project element. TestComplete will display the generated code in the Copy Text to Clipboard dialog. Here, you can copy the generated code to the clipboard and then paste it to your script code.