Smart home cloud service automatic test method and system
By designing a smart home cloud service automation testing method and system that does not rely on physical devices, and using the simulated sending and receiving end to simulate the communication between the cloud, the problem of testing relying on physical devices in the existing technology is solved, and the test is improved The degree of automation and efficiency reduces costs.
Patent Information
- Application Number
- CN202411319699.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2024-11-29
AI Technical Summary
The existing cloud service software testing in the smart home field relies on actual physical devices, limiting the flexibility and efficiency of testing, especially the lack of an effective automated testing framework in the application scenarios of the MQTT protocol.
Design an automated testing method and system for smart home cloud service that does not rely on physical devices. By simulating the communication process between the sending end and the receiving end, the test cases are generated and executed, and the MQTT protocol is used for asynchronous transmission and confirmation. Implement rapid test case generation and execution.
The smart home cloud service testing without relying on physical devices has been realized, which improves the degree of automation and efficiency of testing, reduces labor costs and regression testing costs, and enhances the flexibility and reliability of testing.
Smart Images

Figure CN119052115A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of smart home technology, and more particularly to a smart home cloud service automation testing method and system. Background Art
[0002] Smart home, as the name implies, is a smart home product, which is an intelligent replacement for traditional home. Specifically, the concept of smart home is to use the house as a platform, comprehensively utilize the Internet of Things, cloud computing, artificial intelligence, machine learning and other technologies to upgrade and integrate home life related equipment, so that it has the functions of centralized management, remote control, interconnection, self-learning, etc., to create a convenient, comfortable, healthy, safe and environmentally friendly smart living environment for residents. Smart home uses the family living scene as a carrier, the Internet of Things as a key technology, and integrates automatic control technology, computer technology, and emerging technologies such as big data, artificial intelligence, and cloud computing. It organically combines functions such as home appliance control, environmental monitoring, audio and video entertainment, and information management, and provides a safer, energy-saving, convenient, comfortable and intelligent family life scene through online centralized management of home appliances. At present, smart home products include smart lighting, smart speakers, smart sockets, smart switches and other smart products and smart devices such as sweeping robots and smart home appliances.
[0003] With the improvement of per capita income level of residents, consumers' pursuit of quality of life continues to upgrade, and their requirements for living environment are gradually increasing. Smart home products are gradually entering the general public's homes. New smart home brands have entered the market, and capital entry is driving the industry to further develop and expand.
[0004] In the prior art, cloud service software testing in the smart home field usually relies on actual physical devices, which limits the flexibility and efficiency of testing. Most of the existing interface automation testing frameworks are aimed at the HTTP protocol, while the MQTT protocol is widely used in the smart home field due to its lightweight characteristics. Summary of the invention
[0005] In response to the above problems, the present invention provides a smart home cloud service automation testing method and system, which is an intelligent home cloud service automation testing framework that does not rely on actual physical devices. The framework can simulate the communication process between the device and the cloud to achieve rapid generation and execution of test cases.
[0006] In a first aspect, a method for automated testing of a smart home cloud service includes:
[0007] Generate several device messages and assertion information according to the test cases of the device to be tested, and upload the device messages to the simulated sending end of the test framework, and upload the assertion information to the simulated receiving end of the test framework;
[0008] Send device messages to the cloud service through the simulated sender;
[0009] The cloud service receives the device message, parses and processes it, and sends the processing result to the simulated receiving end;
[0010] The simulated receiving end judges the device message according to the assertion information and outputs the test result;
[0011] Among them, the test framework includes a simulated sending end and a simulated receiving end, and the simulated sending end and the simulated receiving end are respectively connected to the cloud service.
[0012] Furthermore, according to the test case of the device to be tested, several device messages and assertion information are generated, including:
[0013] Each sending device message corresponds to one assertion information, that is, the sending device message and the assertion information correspond one to one.
[0014] Furthermore, each device message sent corresponds to an assertion message, including:
[0015] Each sending device message is associated with the assertion information through a unique sequential ID.
[0016] Furthermore, according to the test case of the device to be tested, several device messages and assertion information are generated, including:
[0017] The sending device message and assertion information constitute a test command, and each test case corresponds to a test command.
[0018] Furthermore, the device message includes the following information:
[0019] UUID, MAC address, user account password, and message information to be sent by the device under test.
[0020] Furthermore, the device message is sent to the cloud service through the simulated sender of the test framework, including:
[0021] The simulation sender sends device messages to the cloud service using asynchronous transmission;
[0022] Add the current timestamp when sending device messages;
[0023] The timestamp specified in the attachment when the cloud service sends the processing result to the simulated receiving end;
[0024] The simulated receiving end confirms the sending order according to the received timestamps.
[0025] Furthermore, the simulation sending end sends the device message to the cloud service, and the cloud service sends the processing result to the simulation receiving end, both using the MQTT protocol.
[0026] Furthermore, the simulated receiving end determines the device message according to the assertion information, including:
[0027] The test framework polls to check whether the simulated receiving end has received the processing result, and asserts whether the processing result is consistent with expectations based on the assertion information. This test passes when the result is consistent with expectations.
[0028] In the second aspect, a smart home cloud service automated testing system includes: a simulation sending end and a simulation receiving end, wherein the simulation sending end and the simulation receiving end are respectively connected to the cloud service
[0029] Generate several device messages and assertion information according to the test cases of the device to be tested, and upload the device messages to the simulated sending end of the test framework, and upload the assertion information to the simulated receiving end of the test framework;
[0030] Send device messages to the cloud service through the simulated sender;
[0031] The cloud service receives the device message, parses and processes it, and sends the processing result to the simulated receiving end;
[0032] The simulated receiving end judges the device message according to the assertion information and outputs the test result.
[0033] In a third aspect, an electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus;
[0034] a memory storing a computer program;
[0035] The processor is used to implement the above-mentioned smart home cloud service automatic testing method when executing the computer program stored in the memory.
[0036] In a fourth aspect, a computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the computer program implements the above-mentioned smart home cloud service automatic testing method.
[0037] The present disclosure has at least the following beneficial effects:
[0038] This paper designs an automated testing framework based on the MQTT protocol to simulate the communication process between smart home devices and the cloud. Using this framework, test cases are quickly generated. Users only need to enter key information, including device UUID, MAC address, user account password, protocol message format and parameter values sent by the device. By simulating the sending and receiving of device status change messages, polling assertions on the received execution message messages are used to verify the processing logic of the cloud service.
[0039] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or be understood by implementing the present disclosure. The purpose and other advantages of the present disclosure can be realized and obtained by the structures indicated in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0041] Figure 1 This is a flow chart of the testing method of the embodiment of the present disclosure;
[0042] Figure 2 This is a schematic diagram of the structure of the test system according to the embodiment of the present disclosure;
[0043] Figure 3 A schematic diagram of the electronic device structure. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present disclosure.
[0045] The present disclosure is used to solve the problems of how to implement smart home cloud service testing that does not rely on physical devices; how to improve the automation level and efficiency of cloud service testing in the smart home field; and how to reduce the manpower cost and regression testing cost of smart home cloud service testing.
[0046] like Figure 1 As shown, a smart home cloud service automated testing method includes:
[0047] S101, generating a number of device messages and assertion information according to the test case of the device to be tested, and uploading the device message to the simulated sending end of the test framework, and uploading the assertion information to the simulated receiving end of the test framework;
[0048] S102, sending device messages to the cloud service by simulating a sending end;
[0049] S103, the cloud service receives the device message, parses and processes it, and sends the processing result to the simulated receiving end;
[0050] S104, simulating the receiving end to judge the device message according to the assertion information and output the test result;
[0051] Among them, the test framework includes a simulated sending end and a simulated receiving end, and the simulated sending end and the simulated receiving end are respectively connected to the cloud service.
[0052] During the specific implementation, the user inputs the relevant information of device A and device B through the test framework, including UUID, MAC address, user account password, and the MQTT message sent by device A and the protocol format and parameter values that device B needs to assert.
[0053] The test framework simulates device B subscribing to its corresponding topic and waiting to receive messages.
[0054] The test framework simulates device A sending a status change message to device A's topic.
[0055] The cloud service receives the MQTT message from device A, parses and processes it, and sends the processing result to the topic subscribed by device B through the MQTT protocol.
[0056] The test framework polls to check whether device B has received the expected execution message message and asserts whether the instructions in the message are consistent with expectations, thereby completing the test.
[0057] In one embodiment, according to the test case of the device to be tested, a number of device messages and assertion information are generated, including:
[0058] Each sending device message corresponds to one assertion information, that is, the sending device message and the assertion information correspond one to one.
[0059] In specific implementation, the one-to-one correspondence between the sending device message and the assertion information facilitates the corresponding test between the test conditions and the test results, and facilitates manual review when the test fails.
[0060] In one embodiment, each sending device message corresponds to one assertion message, including:
[0061] Each sending device message is associated with the assertion information through a unique sequential ID.
[0062] In specific implementation, each sending device message is matched with the assertion information through a unique ID, and an assertion judgment is performed; and whether there are any unreceived device messages is judged through a continuous ID.
[0063] In one embodiment, according to the test case of the device to be tested, a number of device messages and assertion information are generated, including:
[0064] The sending device message and assertion information constitute a test command, and each test case corresponds to a test command.
[0065] During specific implementation, each test case corresponds to a test command, which makes it easy to compare the output test results with the input test cases to facilitate manual review.
[0066] In one embodiment, the device message includes the following information:
[0067] UUID, MAC address, user account password, and message information to be sent by the device under test.
[0068] In one embodiment, sending a device message to a cloud service through a simulated sending end of a test framework includes:
[0069] The simulation sender sends device messages to the cloud service using asynchronous transmission;
[0070] Add the current timestamp when sending device messages;
[0071] The timestamp specified in the attachment when the cloud service sends the processing result to the simulated receiving end;
[0072] The simulated receiving end confirms the sending order according to the received timestamps.
[0073] In specific implementation, asynchronous transmission is used to decouple the sending end from the receiving end, so that the next message can be sent without waiting for a return, thereby increasing execution efficiency. The sending order is confirmed by the timestamp, and combined with the continuous ID, it is determined whether there are any device messages that have not been received.
[0074] In one embodiment, the simulated sending end sends a device message to the cloud service, and the cloud service sends the processing result to the simulated receiving end, both using the MQTT protocol.
[0075] During the specific implementation, the MQTT protocol is used to further decouple sending and receiving, optimize the information transmission process, and receive offline information at the same time to ensure the reliability of the test.
[0076] In one embodiment, the simulation receiving end determines the device message according to the assertion information, including:
[0077] The test framework polls to check whether the simulated receiving end has received the processing result, and asserts whether the processing result is consistent with expectations based on the assertion information. This test passes when the result is consistent with expectations.
[0078] During the specific implementation, on the one hand, it is tested whether the processing result is received, and on the other hand, it is tested whether the processing result is consistent with the expectation. The test passes only when both aspects are met at the same time.
[0079] like Figure 2As shown, a smart home cloud service automatic testing system includes: a simulation sending end and a simulation receiving end, the simulation sending end and the simulation receiving end are respectively connected to the cloud service
[0080] Generate several device messages and assertion information according to the test cases of the device to be tested, and upload the device messages to the simulated sending end of the test framework, and upload the assertion information to the simulated receiving end of the test framework;
[0081] Send device messages to the cloud service through the simulated sender;
[0082] The cloud service receives the device message, parses and processes it, and sends the processing result to the simulated receiving end;
[0083] The simulated receiving end judges the device message according to the assertion information and outputs the test result.
[0084] like Figure 3 As shown, the present disclosure provides an electronic device, including a processor 301, a communication interface 302, a memory 303 and a communication bus 304, wherein the processor 301, the communication interface 302 and the memory 303 communicate with each other through the communication bus 304;
[0085] Memory 303, storing computer programs;
[0086] The processor 301 is configured to implement the above method when executing the computer program stored in the memory 303 .
[0087] The present disclosure provides a computer-readable storage medium storing a computer program, wherein the computer program implements the above method when executed by a processor.
[0088] The computer-readable storage medium may be included in the device / apparatus described in the above embodiment; or it may exist independently without being assembled into the device / apparatus. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0089] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0090] Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein; and these modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure.
Claims
1. A smart home cloud service automated testing method, characterized in that: include: Generate several device messages and assertion information according to the test cases of the device to be tested, and upload the device messages to the simulated sending end of the test framework, and upload the assertion information to the simulated receiving end of the test framework; Send device messages to the cloud service through the simulated sender; The cloud service receives the device message, parses and processes it, and sends the processing result to the simulated receiving end; The simulated receiving end judges the device message according to the assertion information and outputs the test result; Among them, the test framework includes a simulated sending end and a simulated receiving end, and the simulated sending end and the simulated receiving end are respectively connected to the cloud service.
2. The method for automated testing of smart home cloud services according to claim 1, characterized in that: Generate several device messages and assertion information based on the test cases of the device to be tested, including: Each sending device message corresponds to one assertion information, that is, the sending device message and the assertion information correspond one to one.
3. The method for automated testing of smart home cloud services according to claim 2, characterized in that: Each device message sent corresponds to an assertion message, including: Each sending device message is associated with the assertion information through a unique sequential ID.
4. The method for automated testing of smart home cloud services according to claim 1, characterized in that: Generate several device messages and assertion information based on the test cases of the device to be tested, including: The sending device message and assertion information constitute a test command, and each test case corresponds to a test command.
5. The method for automated testing of smart home cloud services according to claim 1, characterized in that: Device message, including the following information: UUID, MAC address, user account password, and message information to be sent by the device under test.
6. The method for automated testing of smart home cloud services according to claim 1, characterized in that: Send device messages to the cloud service through the simulated sender of the test framework, including: The simulation sender sends device messages to the cloud service using asynchronous transmission; Add the current timestamp when sending device messages; The timestamp specified in the attachment when the cloud service sends the processing result to the simulated receiving end; The simulated receiving end confirms the sending order according to the received timestamps.
7. The method for automated testing of smart home cloud services according to claim 1, characterized in that: The simulated sender sends device messages to the cloud service, and the cloud service sends the processing results to the simulated receiver, both using the MQTT protocol.
8. The method for automated testing of smart home cloud services according to claim 1, characterized in that: The simulated receiving end judges the device message based on the assertion information, including: The test framework polls to check whether the simulated receiving end has received the processing result, and asserts whether the processing result is consistent with expectations based on the assertion information. This test passes when the result is consistent with expectations.
9. A smart home cloud service automated testing system, characterized in that: include: Simulate the sending end and the receiving end, and connect the simulated sending end and the simulated receiving end to the cloud service respectively Generate several device messages and assertion information according to the test cases of the device to be tested, and upload the device messages to the simulated sending end of the test framework, and upload the assertion information to the simulated receiving end of the test framework; Send device messages to the cloud service through the simulated sender; The cloud service receives the device message, parses and processes it, and sends the processing result to the simulated receiving end; The simulated receiving end judges the device message according to the assertion information and outputs the test result.
10. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; a memory storing a computer program; The processor is used to implement the smart home cloud service automatic testing method described in any one of claims 1 to 8 when executing the computer program stored in the memory.
11. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, an automated testing method for smart home cloud services as described in any one of claims 1 to 8 is implemented.
