This step of the MQTT Testing tutorial provides information on how to create a connection to the MQTT broker and publish the message to it.
Creating the Topic Publisher Test Case
-
Create an empty ReadyAPI project.
-
Add a test suite and a test case.
-
Add the Publish Using MQTT test step to the test case.
-
Open the new test step.
-
Open the Connection drop-down list and select New Connection.
-
In the Create New Connection dialog, open the General tab.
-
Enter
SampleConnection
in the Name field. ReadyAPI will use this name to identify the connection. -
Enter
broker.hivemq.com
in the Server URL field. -
Click OK.
Note: Other settings are optional, so you do not need to edit them now.
-
Specify the
sampletopic/samplemessage
topic. -
Enter the following phrase as the message contents:
Current temperature is 30 degrees.
Testing the Connection
Click on the ReadyAPI toolbar to check if the connection works.
ReadyAPI will connect to the broker and send the message you have specified in the connection properties earlier. You can expand the Log tab to see whether the message was published successfully.
Now, you can use the Receive MQTT Message test step to receive information from the broker.