WebSocket Plugin

Applies to ReadyAPI 3.57, last modified on December 20, 2024
Note: For more information on the plugin, please refer to SmartBear/ready-websocket-plugin.

This plugin adds four TestSteps to the functional testing in ReadyAPI:

  • Publish: Sends messages to a WebSocket server.
  • Receive: Receives and asserts messages.
  • Drop: Drops the connection to the WebSocket server.
  • Open: Opens a connection to the WebSocket server.

The plugin integrates seamlessly with ReadyAPI features such as property expansion, property transfers, and data-driven testing.

The plugin was inspired by the SmartBear/ready-websocket-plugin, with contributions from its original authors.

Requirements and Installation

This plugin has been tested with the following versions:

  • SoapUI 5.7.2
  • ReadyAPI 3.53.0

Working with the JIRA plugin

Install the plugin via the Plugin Manager in ReadyAPI.

For detailed instructions, see the ReadyAPI Plugin Manager guide.

Currently, this plugin is at v2.1.1

WebSocket Test Steps

This plugin adds four WebSocket TestSteps for interacting with WebSocket servers:

  1. Publish using WebSockets: Publishes a message to the server.
  2. Receive WebSocket Message: Receives a message from the server.
  3. Drop WebSocket Connection: Closes or terminates the connection with the server.
  4. Open WebSocket Connection: Opens a connection to the server.

Lifetime of WebSocket Connections

WebSockets are full-duplex, single TCP socket connections that allow simultaneous communication in both directions. Messages can be published and received on the same connection.

In a TestCase, WebSocket TestSteps are used, and open WebSocket connections are cached for reuse. Each WebSocket TestStep checks the cache for an existing connection by name. If a matching open connection is found, it will be used; otherwise, a new connection will be established and cached. Once the TestCase completes, all open WebSocket connections will be closed.

Note:
  • Caching and reuse of WebSocket connections occur only when running a TestCase. For a single WebSocket TestStep, the connection is not cached.
  • During a LoadTest, connections are reused across all threads unless the Close Connection option is selected in the LoadTest Options dialog.

Configure WebSocket Connections

Before starting, specify the WebSocket server and configure the connection settings. Each WebSocket TestStep includes a Connection combo-box where you can choose an existing connection or select <New Connection…> to create a new one.

The Create Connection dialog will appear, where you will need to provide the following settings for the connection (note that only project-level property expansions will work correctly for connection settings):

Create WebSocket Connection Dialog

Click the image to enlarge it.

Setting Description
Name A unique identifier for the connection, visible in the "Connection" combo-box in test steps.
Server URI A unique identifier for the connection, visible in the "Connection" combo-box in test steps.
Sub-protocols Optional sub-protocols for the WebSocket upgrade request, entered as a comma-separated list.
Authentication Check this if the WebSocket server requires authentication.
Login and Password Required if authentication is enabled.
Hide If unchecked, the password is visible. Check to hide the password.

Once you click OK to close the Create Connection dialog, the connection will be assigned to the current test step. To reuse the connection in other test steps, select it from the Connection combo-box in the test step editor.

Managing Connections

To view or remove project-related connections, open any Publish or Receive test step editor and click the Configure WebSocket Connections of the Project toolbar button. This will open the Configure Connections to WebSocket Servers dialog, where you can manage all connections for the project.

Managing WebSocket Connections in Project

Click the image to enlarge it.

WebSocket Test Steps

Publish Using WebSockets

This test step publishes a message to the selected server.

Setting Description
Connection Select the WebSocket server or choose <New Connection…> to create a new connection for this test step.
Configure Click this button to customize the selected connection. The Configure Connection dialog will appear.
Message Type

Select the type of message to publish. Available options:

  • Send as WebSocket text message:

    • JSON
    • XML
    • Text
  • Send as WebSocket binary message:

    • Content of file
    • Integer (4 bytes)
    • Long (8 bytes)
    • Float
    • Double
Message Enter the payload for the message you want to publish.
Timeout Set the time limit for the test step. If the connection cannot be established or the message cannot be sent within the specified period, the test step will fail.
Publish WebSocket Connection Test Step Configuration

Click the image to enlarge it.

Receive WebSocket Message

This test step waits for a message from the WebSocket server and optionally asserts the message.

Setting Description
Connection Select the WebSocket server or choose <New Connection…> to create a new connection for this test step.
Configure Click to customize the selected connection. The Configure Connection dialog will appear.
Expected Message Type

Specify the expected type for the received message. Available options:

  • Text (UTF-8)
  • Raw binary data (shown as a hexadecimal sequence)
  • Integer number
  • Float number
Timeout The test step will fail if a valid message isn't received within a specified period.
Stop After The test step will stop receiving after the specified number of messages.
Count The total number of messages processed by the WebSocket client. The client may continue receiving additional messages before it is stopped.
Received Message Displays the payload of the received message from the WebSocket server.
Assertions If assertions are present, they will be applied to the received stream of messages. The test step succeeds only if all assertions match. Without assertions, the first received message is valid.
Receive WebSocket Message Test Step Configuration

Click the image to enlarge it.

Drop WebSocket Connection

This test step disconnects from the WebSocket server, useful when testing scenarios with dropped connections. This step has no effect during a LoadTest.

Setting Description
Connection Select the WebSocket server or choose <New Connection…> to create a new connection for this test step.
Configure Click to customize the selected connection. The Configure Connection dialog will appear.
Drop Method

Choose the method for disconnecting the WebSocket connection:

  • Send Normal Close message: Sends status code 1000 and a reason message to close the connection.
  • Send Protocol Error message: Sends status code 1002 and a reason message indicating a protocol error when closing the connection.
Drop WebSocket Connection Test Step Configuration

Click the image to enlarge it.

Open WebSocket Connection

This test step connects to the WebSocket server, useful for testing scenarios where connections should be created before any other non-WebSocket test step.

Setting Description
Connection Select the WebSocket server or choose <New Connection…> to create a new connection for this test step.
Configure Click to customize the selected connection. The Configure Connection dialog will appear.
Timeout

The test step will fail if the connection cannot be established within the specified period.

See Also

Integrations Tab

Haven’t used ReadyAPI yet?
Highlight search results