About Publish Using MQTT test step
Use this test step to simulate actions of an MQTT publisher. The test step connects to the MQTT broker and sends the message to it.
Editing Publish Using MQTT test step
You can modify settings of a test step in its editor:
Connection to MQTT server
Connection
Choose a configured connection to the broker from the drop-down list, or select <New Connection...> to create a new connection. Click Configure to customize properties of the selected connection in the Configure Connection dialog.
Published message
Topic
Enter the message topic. Only clients subscribed to this topic will receive the message.
Message type
Select the encoding of the published message. If possible, ReadyAPI will display the corresponding editor. Available values include --
- JSON
- XML
- Text (UTF-16)
- Text (UTF-8)
- Content of file
- Integer
- Long (8 bytes)
- Float
- Double
Notes:
-
If the JSON or XML message type is selected, the message is sent as UTF-8 text.
-
Numeric messages are always sent as binary data.
Message
The Text and Tree View panels show the contents of the message.
Message delivering settings
Quality of Service
Choose the Quality of Service you want to use when delivering the message to the broker. Available values:
Value | Description |
---|---|
At most once (0) | The publisher sends the message once and does not check whether the broker received the message. As a result, the broker may or may not receive the message. |
At least once (1) | The publisher keeps sending the message until the broker acknowledges that it has received the message. As a result, the broker may receive the same message more than once. |
Exactly once (2) | The publisher makes sure that the broker received the message and that the message was received only once. |
Retained
Select this check box to store the message on the broker. If you do, all new clients subscribing to the topic will receive the message.
Timeout
Specify how long ReadyAPI waits for the connection to the MQTT broker.
Configure connection dialog
Use the Configure Connection dialog to configure connections used by the test step. You use the same dialog to create a new connection or to update the connection from a legacy version.
The General tab
The connection may be used in any test case in the project, so only project-level property expansions will work correctly for connection settings. |
Name
Server URL
The MQTT server's URL.
The URL should contain tcp://
when connecting to a TCP socket or ssl://
when connecting to an SSL socket.
The URL may also contain a port number. If the port is not specified, ReadyAPI will use port 1883
for TCP URLs, and 8883
for SSL URLs.
Client ID
The client identifier is used by the server to identify a client. It must be unique across all clients connecting to the same server. This field is optional. If it is empty, a unique client identifier will be generated for every test case run.
Clean Session
Select this check box to create a new connection each time you run the test. If this check box is clear, ReadyAPI and the tested MQTT server will store the session state to enable reliable messaging across several connections. For example, if the connection is lost during the test case run, the Receive MQTT Message test step will still catch messages if it can reconnect.
Authentication
Enable the check box if the MQTT server requires authentication.
Login
The user name for connecting to the MQTT server.
Password
The user password for connecting to the MQTT server.
Will message
If you enable storing Will messages on the MQTT server, this message will be send to listeners if the "publisher" client disconnects from the server without sending the Disconnect message.
Topic
Enter the message topic. Only clients subscribed to this topic will receive a message published by this test step.
Message type
Select the message encoding. Available values include --
- JSON
- XML
- Text (UTF-16)
- Text (UTF-8)
- Content of file
- Integer
- Long (8 bytes)
- Float
- Double
Notes:
-
If the JSON or XML message type is selected, the messages are sent as UTF-8 text.
-
Numeric messages are always sent as binary data.
Message
The contents of the message.
Quality of Service
Choose the Quality of Service you want to use when delivering the message. Available values:
Value | Description |
---|---|
At most once (0) | The sender does not check whether the message was received. |
At least once (1) | The sender makes sure that the message was received at least once, but does not check whether it was delivered more than once. |
Exactly once (2) | The sender makes sure that the message was received only once. |
Retained
If selected, the Will message will be a retained message: it will be stored on the broker and sent to all new clients subscribing to the topic.
SSL properties
CA certificate
Specifies a fully-qualified path to the certificate of the certificate authority (CA) that signed the server certificate.
Client certificate
Specifies a fully-qualified path to a certificate that will be used to sign messages.
Key file
Specifies a fully-qualified path to the client’s private key.
Key password
The password from the specified key file.
SSL server name
The server to which you want to connect. Typically, it is the same as Server URL.
Note: | You can connect by specifying the CA certificate without filling in the other parameters. |
Property list
Besides the test step editor, you can adjust the test step’s behavior by using its properties in the Properties and Custom Publish using MQTT Test Step Properties panels in the Navigator.
Properties | View ↓
Name | Description |
---|---|
Description |
Text describing the test step. |
Name |
The test step’s name. |
Name | Description |
---|---|
Name |
The test step’s name. |
Description |
Text describing the test step. |
Custom Publish using MQTT Test Step Properties | View ↓
Values on the Custom Publish using MQTT Test Step Properties tab are available to other test steps in your project. For instance, you can verify these property values with the Assertion test step, or check them and change the execution flow with the Conditional GoTo test step.
You can load values of custom properties from a file, or save them to a file. To learn more, see About Properties.
This tab contains the following properties that provide access to the request and response data.
Name | Description | ||
---|---|---|---|
CertCAPEM |
Specifies the fully-qualified path to the CA certificate that was used to sign the server certificate.
|
||
CertClientPEM |
Specifies the fully-qualified path to the client’s certificate that will be used to sign messages.
|
||
CertKeyPassword |
Specifies the password for the client’s private key file.
|
||
CertKeyPEM |
Specifies the fully-qualified path to the client key file.
|
||
CertSniServer |
Specifies the host name of the server, to which you want to connect.
|
||
ClientID |
The client identifier is used by the server to identify a client.
|
||
Login |
The user name for connecting to the MQTT server.
|
||
Message |
The contents of the message.
|
||
MessageType |
Encoding of the published message.
|
||
Password |
The user password for connecting to the MQTT server.
|
||
QoS |
Specifies the Quality of Service. Possible values:
|
||
ServerURI |
Specifies the MQTT server’s URL with the used protocols.
|
||
Timeout |
Specifies how long ReadyAPI waits for the connection to the MQTT broker (in milliseconds).
|
||
Topic |
The message’s topic.
|
Name | Description | ||
---|---|---|---|
ServerURI |
Specifies the MQTT server’s URL with the used protocols.
|
||
Message |
The contents of the message.
|
||
Timeout |
Specifies how long ReadyAPI waits for the connection to the MQTT broker (in milliseconds).
|
||
CertKeyPEM |
Specifies the fully-qualified path to the client key file.
|
||
CertSniServer |
Specifies the host name of the server, to which you want to connect.
|
||
Login |
The user name for connecting to the MQTT server.
|
||
CertKeyPassword |
Specifies the password for the client’s private key file.
|
||
CertCAPEM |
Specifies the fully-qualified path to the CA certificate that was used to sign the server certificate.
|
||
QoS |
Specifies the Quality of Service. Possible values:
|
||
ClientID |
The client identifier is used by the server to identify a client.
|
||
CertClientPEM |
Specifies the fully-qualified path to the client’s certificate that will be used to sign messages.
|
||
Topic |
The message’s topic.
|
||
MessageType |
Encoding of the published message.
|
||
Password |
The user password for connecting to the MQTT server.
|
Logging
If the test step is run as part of a test case, you can see the test log in the Transaction Log panel.
See Also
About IoT MQTT Testing
MQTT Testing Tutorial
Receive MQTT Message Test Step
Drop MQTT Connection Test Step
Test Steps