Chapter 5. Test Cases

Table of Contents

5.1. Create a Test Case
5.2. Set Up the Actors
5.3. Add Events
5.4. Add an Operation
5.5. Create a Template
5.6. Insert the Template
5.7. Add Server's Response
5.8. Add Assertions

A PETA test case specifies the scenario that shall be tested similar to the well-known UML sequence diagrams. It describes the (expected) message flow between the actors and the data of the exchanged messages. Additionally, assertions are defined to validate the correct behavior of the system. Events are used to define the actions that an actor performs during the test scenario. An event is triggered by the reception of a message from another actor or by the ending of a previous event of the same actor without sending an own message. The adding of an event is described in Section 5.3, “Add Events”.

An event consists of (one or more of) an operation , assertions , and/or settings of context values. The operation is used to define the sending of a message to another actor. Adding an operation is shown in Section 5.4, “Add an Operation”.

The message's data is defined as an XML document that is normally retrieved from a template which can be manipulated before sending by composition, omission or substitution operations. The template's creation and usage in an operation is shown in Section 5.5, “Create a Template” and Section 5.6, “Insert the Template”.

Assertions are used to define expected results, for example to validate the data of received messages. The adding of assertions is shown in Section 5.8, “Add Assertions”.

Context values represent global variables that are visible to all actors. They may be used to store data that is needed later in a test case, for example to perform assertions of values, to temporarily store return values of plug-ins or as input and output parameters of PETA modules. The usage of context values will be shown later in this tutorial in Chapter 8, Modules.

[Note]Further information

Detailed information about PETA test cases can be found in the PETA Core Reference Manual.

5.1. Create a Test Case

After setting up the test project, the first PETA test case can be created. In this test case, the client sends a valid request to get the course list, the server validates the request and sends back the course list to the client, which successfully checks the response.

To create a new test case for this scenario, use the Create a new test case button in the toolbar, that will pop up the New Case wizard. Leave the selection on the path peta/case, enter requestCourseList as the test case (file) name, and press the Next button.

Figure 5.1. Create a new test case

Create a new test case


On the second page, enter a description of the test case and create it by pressing the Finish button. The new test case will be opened in the PETA editor.

Figure 5.2. Test case annotation

Test case annotation