WebSocket Testing Engine docs: the Library


5. Execution paths

The flowchart below depicts execution of single unit inside WSTester:

And this is how WSTester handles WebSockets messages:

Note that "Fail unit" node simply leads to the message "Got irrelevent data". A flow cannot be failed before the waiting_time exceeding, it will just wait for an appropriate message.

6. Using WSTester library

To process flows you have to create a controller object by execution of WSTester.Controller function with dictionary as an argument. The dictionary may contain the following fields:

  • flows – array of flows (each flow is an array or a dictionary with unit objects). Required property.

  • server – URL of WebSockets server. Required property.

  • waiting_time – waiting time before current unit fails if there is no appropriate message found. Default value: 2000 (2 seconds).

  • delay – amount of time before between end of one unit and beginning of another. Default value: 0.

  • split – if set, each flow gets a new WebSockets connection. Default value: false.

  • add – function for output, have the following arguments: string for output and an integer number, type of the output. The type may be: 0 (general info), 1 (content of sent and received messages), 2 (good news), and 3 (bad news, errors).

  • work_begin – function that is called every time new WebSocket connection established. Therefore, depending on the value of split, the function may be called on the start of first or each flow. It takes no arguments.

  • work_end – function that is called after completion of all the flows. It takes these numbers as arguments: count of passed flows, count of failed flows, and total number of the flows.

All the arguments are used in WSTester GUI, so, you can open the source code and check an example of the library usage.