5.8. Add Assertions

The message flow of the test case has been defined, but nothing is checked. It is expected that the client receives the course list as described in the template after sending the valid getCourseList request. If the client receives something else, the test case must fail. Therefore, it shall be asserted, that

To simplify this tutorial example, further possible assertions are ignored.

To assert the reception of a course list, drag'n'drop the Add Assertion symbol from the palette to the client's second event. In the assertion wizard, enter course list received as the name of this assertion, set the operator to exists, press the Add Document button to indicate that a document's value has to be checked, press the Add Constant button and enter the XPath /courseList.

Figure 5.13. Add an assertion

Add an assertion


Finish adding of the assertion by pressing the OK buttons.

To assert the reception of exact two courses, repeat these steps for adding

To assert the name of the first course, add an assertion, enter first course is Computer Engineering as the name, set the operator to == and the data type to String . To specify the document path that shall be asserted, press the Add Document button, press the Add Constant button and enter /courseList/course[1]/name to address the name of the first course in the received document. Press the right Add Constant button to enter the expected value Computer Engineering. Repeat these steps with XPath /courseList/course[2]/name and the constant value Software Engineering I to assert the second course's name. Additionally, two exists assertion to check the existence of the courses' names may be added before asserting the values.

To simulate the behavior of the server, assertions can be added to the server's event, too. While receiving a request, the server validates the request and checks its type to determine how to handle it. Therefore, the following assertions can be added to the server's event:

After adding these assertions, the test case should look like shown in the following image.

Figure 5.14. Test case after adding assertions

Test case after adding assertions