The invention discloses an MQTT server interface test method and system, which relates to the technical field of network communication. The MQTT server interface test method includes: acquiring the MQTT server interface test case; publishing and subscribing preset messages to the MQTT server to be tested according to the interface test case, and subscribing to the subscribed messages. The content is checked and the test results are generated according to the checking results. In this application, the test of MQTT server interface is standardized through interface test cases; according to interface test cases, preset messages are published and subscribed to the MQTT server to be tested, and the subscribed messages are verified; and test results are generated according to the verification results. The technical solution provided in this application can automatically test the MQTT server interface and output the test results after compiling the interface test cases in a specific format.
【技术实现步骤摘要】
一种MQTT服务器接口测试方法及系统
本专利技术涉及网络通信
,尤其涉及一种MQTT服务器接口测试方法及系统。
技术介绍
MQTT(MessageQueuingTelemetryTransport,消息队列遥测传输)是IBM开发的一个即时通讯协议,在物联网中应用较多。MQTT最大优点在于,可以以极少的代码和有限的带宽,为连接远程设备提供实时可靠的消息服务。做为一种低开销、低带宽占用的即时通讯协议,使其在物联网、小型设备、移动应用等方面有较广泛的应用。现阶段的一些接口自动化测试方案一般都只支持HTTP协议,由于MQTT采用的是发布和订阅的模式,所以现阶段的接口自动化测试方案也无法兼容MQTT服务器接口的测试。对于HTTP接口的测试,一般是对特定的请求验证其响应是否符合预期。例如公开号为CN107797911A的专利文献公开了用于测试HTTP接口的方法和装置,其中,该方法包括:获取用户输入的针对待测试超文本传输协议HTTP接口的测试用例;将所述测试用例中的第一个测试步骤作为当前测试步骤,并执行以下HTTP接口测试步骤:将所述当前测试步骤的测试操作和测试数据封装成HTTP测试请求包并发送到所述待测试HTTP接口;判断所述待测试HTTP接口返回的响应数据是否与所述当前测试步骤的期望结果数据相同,如果不同,则生成测试失败的结果;如果相同,则进一步判断所述当前测试步骤是否是所述测试用例的最后一个步骤,如果是,则生成测试成功的结果;如果不是,则将下一测试步骤作为当前测试步骤,继续执行所述HTTP接口测试步骤。该专利文献提供的HTTP接口测试方法是通过验证待测试HT ...
【技术保护点】
1.一种MQTT服务器接口测试方法,其特征在于,包括:获取MQTT服务器的接口测试用例;根据所述接口测试用例,向待测试的MQTT服务器发布和订阅预设消息,并对订阅的消息内容进行校验;根据校验结果,生成测试结果。
【技术特征摘要】
1.一种MQTT服务器接口测试方法,其特征在于,包括:获取MQTT服务器的接口测试用例;根据所述接口测试用例,向待测试的MQTT服务器发布和订阅预设消息,并对订阅的消息内容进行校验;根据校验结果,生成测试结果。2.根据权利要求1所述的MQTT服务器接口测试方法,其特征在于,所述获取MQTT服务器的接口测试用例包括:读取MQTT服务器的接口测试用例文件;其中,所述接口测试用例文件为YAML不是一种标记语言(YMAL)格式文件或JS对象简谱(JSON)格式文件;确定所述接口测试用例文件中包含的至少一条接口测试用例。3.根据权利要求1所述的MQTT服务器接口测试方法,其特征在于,所述根据所述接口测试用例,向待测试的MQTT服务器发布和订阅预设消息,并对订阅的消息内容进行校验,具体包括:根据所述接口测试用例生成测试会话对象;调用所述测试会话对象,以向待测试的MQTT服务器发布和订阅预设消息,并对订阅的消息内容进行校验。4.根据权利要求1所述的MQTT服务器接口测试方法,其特征在于,还包括:发送包含所述测试结果的邮件至预设邮箱。5.根据权利要求1所述的MQTT服务器接口测试方法,其特征在于,所述接口测试用例至少包括:发布的主题和消息内容、订阅的主题、需要校验的内容和预期值。6.一种...
【专利技术属性】
技术研发人员:陈超,
申请(专利权)人:四川斐讯全智信息技术有限公司,
类型:发明
国别省市:四川,51
还没有人留言评论。发表了对其他浏览者有用的留言会获得科技券。