Automatic testing method and system for swan-mongolian equipment, terminal and medium

By creating a WebSocket server on the test platform and setting port forwarding rules, the problem of low efficiency in the existing technology of relying on the network environment for WebSocket testing is solved, and efficient and flexible automated testing is achieved.

CN119512936APending Publication Date: 2025-02-25深圳开鸿数字产业发展有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411511042.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-28
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the prior art, it is necessary to rely on the network environment to perform WebSocket testing on clients installed with OpenHarmony system, resulting in lower testing efficiency and higher cost.

Method used

By creating a WebSocket server on the test platform, establishing a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmenghua device, establishing a physical link between the target Hongmenghua device and the test platform, and setting port forwarding rules to establish a logical link between the target Hongmenghua device and the WebSocket server, and realizing automated testing.

Benefits of technology

This method significantly improves the efficiency of WebSocket testing on devices installed with OpenHarmony system. The test process no longer depends on the network, improves the flexibility of the test, and ensures the accuracy of the test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512936A_ABST
    Figure CN119512936A_ABST
Patent Text Reader

Abstract

The invention provides an automatic test method and system of a swan-monted device, a terminal and a medium, and particularly relates to the technical field of swan-monted device tests.The scheme comprises the steps that a WebSocket server is created on a test platform, a mapping relation between a source port of the WebSocket server and a local port of a target swan-monted device is established, and a first mapping relation is obtained; establishing a physical link between the target swan equipment and the test platform, and setting a port forwarding rule which represents a forwarding rule between a local port and a source port established through the test platform; based on the port forwarding rule and the first mapping relationship, establishing a logic link between the target swan equipment and the WebSocket server; and carrying out automatic testing on the WebSocket server or the target gap equipment based on the logic link to generate a test result. The scheme does not depend on a network any more, and the testing flexibility can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of Hongmeng device testing technology, and in particular to an automated testing method, system, terminal and medium for Hongmeng devices. Background Art

[0002] In the prior art, when performing a WebSocket test on a client with an OpenHarmony system installed, it is usually necessary to establish a connection between the device and the Websocket server, and it is inevitable to connect to the network or use a local area network for testing. However, in some cases, directly connecting to an external network or using a local area network may not be convenient or feasible, and the network test environment is relatively complicated to set up, and the test effect is easily affected by the network environment, resulting in low test efficiency and high test costs. Summary of the invention

[0003] In view of the above-mentioned deficiencies in the prior art, the object of the present invention is to provide an automated testing method, system, terminal and medium for Hongmeng devices, aiming to solve the problems in the prior art of low testing efficiency and high cost caused by the need to rely on the network environment to perform WebSocket testing on the client.

[0004] In order to achieve the above-mentioned object, the first aspect of the present invention provides an automated testing method for a Hongmeng device, comprising:

[0005] Create a WebSocket server on the test platform, and establish a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmeng device to obtain a first mapping relationship;

[0006] Establish a physical link between the target Hongmeng device and the test platform, and set a port forwarding rule, where the port forwarding rule indicates a forwarding rule for establishing the local port and the source port through the test platform;

[0007] Based on the port forwarding rule and the first mapping relationship, establish a logical link between the target Hongmeng device and the WebSocket server;

[0008] Based on the logical link, the WebSocket server or the target Hongmeng device is automatically tested to generate test results.

[0009] Optionally, establishing a physical link between the target Hongmeng device and the test platform includes:

[0010] Pre-install a device driver for the target Hongmeng device;

[0011] Based on the device driver, a physical link between the target Hongmeng device and the test platform is established.

[0012] Optionally, the setting of port forwarding rules includes:

[0013] Set up several transit ports on the test platform;

[0014] Establishing a mapping relationship between the transit port and the source port of the WebSocket server to obtain a second mapping relationship;

[0015] A port forwarding rule is set based on the first mapping relationship and the second mapping relationship.

[0016] Optionally, establishing a logical link between the target Hongmeng device and the WebSocket server based on the port forwarding rule and the first mapping relationship includes:

[0017] Installing the OpenHarmony HDC tool on the test platform and starting the port forwarding function of the OpenHarmony HDC tool;

[0018] Based on the port forwarding rule, setting the port forwarding parameters of the transit port;

[0019] Based on the port forwarding parameters and the first mapping relationship, a logical link is established between the target Hongmeng device and the WebSocket server.

[0020] Optionally, the performing automated testing on the WebSocket server or the target Hongmeng device based on the logical link to generate a test result includes:

[0021] Get the WebSocket server test script;

[0022] Establishing a connection between the server test script and the WebSocket server, and sending first test information to the WebSocket server;

[0023] In response to receiving first response information from the WebSocket server to the first test information, the first test information and the first response information are compared to generate a test result for the WebSocket server.

[0024] Optionally, comparing the first test information and the first response information to generate a first test result includes:

[0025] Comparing the first test information with the first response information to obtain a first comparison result;

[0026] The function of the MQTT protocol is verified using the first comparison result to generate a first test result.

[0027] Optionally, the performing automated testing on the WebSocket server or the target Hongmeng device based on the logical link to generate a test result further includes:

[0028] Get the target Hongmeng device test script;

[0029] Establish connections between the device test script and the WebSocket server and the target Hongmeng device respectively, and send second test information to the target Hongmeng device;

[0030] In response to receiving the second response information of the target Hongmeng device to the second test information, the second test information and the second response information are compared to generate a test result for the target Hongmeng device.

[0031] A second aspect of the present invention provides an automated testing system for Hongmeng devices, the system comprising:

[0032] An information acquisition module is used to create a WebSocket server on the test platform and establish a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmeng device to obtain a first mapping relationship;

[0033] A port forwarding rule construction module, used to establish a physical link between the target Hongmeng device and the test platform, and set a port forwarding rule, wherein the port forwarding rule indicates a forwarding rule between the local port and the source port established through the test platform;

[0034] A logical link establishment module, used to establish a logical link between the target Hongmeng device and the WebSocket server based on the port forwarding rule and the first mapping relationship;

[0035] A testing module is used to perform automated testing on the WebSocket server or the target Hongmeng device based on the logical link and generate test results.

[0036] A third aspect of the present invention provides a smart terminal, which includes a memory, a processor, and an automated testing program for Hongmeng devices stored in the memory and executable on the processor. When the automated testing program for Hongmeng devices is executed by the processor, the steps of any one of the automated testing methods for Hongmeng devices are implemented.

[0037] A fourth aspect of the present invention provides a computer-readable storage medium, on which an automated testing program for Hongmeng devices is stored. When the automated testing program for Hongmeng devices is executed by a processor, the automated testing program for Hongmeng devices implements the steps of any one of the above-mentioned automated testing methods for Hongmeng devices.

[0038] Compared with the prior art, the beneficial effects of this solution are as follows:

[0039] The present invention sets a transit port, establishes a port mapping relationship between the target Hongmeng device and the transit of the test platform, establishes a port mapping relationship between the test platform and the WebSocket server, and sets port forwarding rules to simultaneously support the testing of WebSocket servers in non-network environments or network environments, and can ensure that data can be effectively transmitted between the target Hongmeng device, the test platform and the WebSocket server, thereby realizing automated testing of the WebSocket server or the target Hongmeng device. On the basis of ensuring the accuracy of the test results, the efficiency of WebSocket testing of devices installed with the OpenHarmony system is significantly improved, and the test process no longer depends on the network, thereby improving the flexibility of the test. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, 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 only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0041] Figure 1 This is a flow chart of the automated testing method for Hongmeng devices of the present invention;

[0042] Figure 2 This is a schematic diagram of the automated testing system module for Hongmeng devices of the present invention;

[0043] Figure 3 It is a schematic diagram of the structure of the intelligent terminal of the present invention. DETAILED DESCRIPTION

[0044] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present invention. However, it should be clear to those skilled in the art that the present invention may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present invention.

[0045] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0046] It should also be understood that the terms used in the present specification are only for the purpose of describing specific embodiments and are not intended to limit the present invention. As used in the present specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0047] It should be further understood that the term "and / or" used in the present description and the appended claims refers to any and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0048] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0049] The following is a clear and complete description of the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0050] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0051] In view of the problem in the technology that the WebSocket test on the client needs to rely on the network environment, which leads to low testing efficiency and high cost, the present invention proposes an automated testing method for Hongmeng devices, which mainly creates a WebSocket server on a test platform, and establishes a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmeng device to obtain a first mapping relationship; establishes a physical link between the target Hongmeng device and the test platform, and sets port forwarding rules, the port forwarding rules represent the forwarding rules for the local port and the source port established through the test platform; establishes a logical link between the target Hongmeng device and the WebSocket server based on the port forwarding rules and the first mapping relationship; performs automated testing on the WebSocket server or the target Hongmeng device based on the logical link to generate test results. This method sets a transit port, establishes a port mapping relationship between the target Hongmeng device and the transit of the test platform, establishes a port mapping relationship between the test platform and the WebSocket server, and sets port forwarding rules to simultaneously support the testing of WebSocket servers in non-network environments or network environments, and can ensure that data can be effectively transmitted between the target Hongmeng device, the test platform and the WebSocket server, thereby realizing automated testing of the WebSocket server or the target Hongmeng device. On the basis of ensuring the accuracy of the test results, the efficiency of WebSocket testing on devices installed with the OpenHarmony system is significantly improved, and the test process is no longer dependent on the network, which improves the flexibility of the test and is conducive to providing strong support for subsequent improvements and optimizations.

[0052] The embodiment of the present invention provides an automated testing method for Hongmeng devices, which is deployed on electronic devices such as computers and servers and is applied to scenarios where WebSocket testing of devices installed with the OpenHarmony system does not require reliance on the network. Figure 1 As shown, the steps of the method in this embodiment include:

[0053] Step S100: Create a WebSocket server on the test platform, and establish a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmeng device to obtain a first mapping relationship;

[0054] Specifically, WebSocket server software is installed on a test platform compatible with Hongmeng devices, such as Node.js's ws library, Java's Spring WebSocket, etc. Configure the WebSocket server, including setting the listening port, processing connection requests, sending and receiving messages, etc. Among them, for the setting of the listening port, determine the local port of one or more types of target Hongmeng devices that need to be measured, and register the source port corresponding to the local port of the target Hongmeng device on the WebSocket server. Set the port mapping rules to specify the source port (WebSocket server port of the test platform), the target IP address (IP address of the Hongmeng device) and the target port (local port of the Hongmeng device). Then, according to the port mapping rules, complete the port mapping settings and try to connect to the WebSocket server through the test platform. If the connection is successful and the message from the test platform can be received on the Hongmeng device, it means that the port mapping relationship has been successfully established. It can be seen that by creating a WebSocket server and setting the port mapping relationship, the mapping relationship between the source port and the local port of the target Hongmeng device is realized, which lays the foundation for the subsequent testing and verification of the WebSocket communication function of the Hongmeng device on the test platform.

[0055] Step S200: establishing a physical link between the target Hongmeng device and the test platform, and setting a port forwarding rule, wherein the port forwarding rule indicates establishing a forwarding rule between the local port and the source port through the test platform;

[0056] Specifically, ensure that the target Hongmeng device is compatible with the test platform, including the OpenHarmony operating system version, hardware interface, communication protocol, etc. For example, ensure that the OpenHarmony system version installed on the target Hongmeng device is compatible with the OpenHarmonyHDC tool version of the test platform. Prepare the corresponding connection cables according to the device's interface type (such as USB, HDMI, network cable, etc.); ensure that the test platform has been correctly installed and configured with the required test software and tools, and check whether the test platform's power supply, network connection and other infrastructure are stable and reliable.

[0057] On the target Hongmeng device, enter the developer options, turn on the USB debugging mode (or other corresponding debugging modes), and use the connecting wire to connect the target Hongmeng device to the corresponding interface of the test platform. If the test platform requires a specific driver to identify or communicate with the target Hongmeng device, install the device driver for the target Hongmeng device in advance, and establish a physical link between the target Hongmeng device and the test platform based on the device driver. On the test platform, use the corresponding test software or tools to check the connection status of the target Hongmeng device to ensure that the device can be correctly identified and can communicate and transmit data.

[0058] Then configure the port forwarding rules. Specifically, open the browser, enter the IP address of the router, select service types such as TCP, UDP or TCP / UDP, specify the port number used by the test platform to access the target Hongmeng device, enter the IP address of the target Hongmeng device, and specify the port number listened by the WebSocket service or application on the target Hongmeng device to configure the port forwarding rules.

[0059] Through the above steps, this embodiment can successfully establish a physical link between the target HarmonyOS device and the test platform, and set port forwarding rules to achieve forwarding of local ports and source ports, which is helpful to test and verify the network communication function of the HarmonyOS device on the test platform.

[0060] In a preferred embodiment, setting the port forwarding rule in step S200 includes:

[0061] Step S210: Setting a number of transfer ports on the test platform;

[0062] Step S220: establishing a mapping relationship between the transit port and the source port of the WebSocket server to obtain a second mapping relationship;

[0063] Step S230: Setting a port forwarding rule based on the first mapping relationship and the second mapping relationship.

[0064] Specifically, first, according to the test requirements, determine the number of transit ports that need to be set on the test platform. On the firewall or router of the test platform, configure a unique port number for each transit port to ensure that these transit ports are not occupied by other services.

[0065] Then, determine the WebSocket server source port, specifically, confirm the source port number that the WebSocket server listens on the test platform. Create a mapping between the transit port and the source port: In the network configuration of the test platform, create a mapping rule for each transit port, mapping each transit port to the source port of the WebSocket server. This usually involves configuring static port forwarding or dynamic port forwarding rules in the NAT (network address translation) settings of the firewall or router.

[0066] Finally, set the port forwarding rules, specifically, according to the first mapping relationship between the local port of the target Hongmeng device and the transit port of the test platform (the local port of the target Hongmeng device -> the transit port 1 of the test platform), and the second mapping relationship between the transit port of the test platform and the source port of the WebSocket server (the transit port 2 of the test platform -> the source port of the WebSocket server. Among them, the transit port 1 and the transit port 2 of the test platform are used to distinguish the transit ports used in the first mapping relationship and the second mapping relationship. The transit port 1 and the transit port 2 can be the same or different, mainly depending on the specific configuration. The specific rules are: when the target Hongmeng device requests to access a certain transit port of the test platform through a port When forwarding the port, the request is forwarded to the source port of the WebSocket server, ensuring that the request sent from the target Hongmeng device can be correctly forwarded to the transit port of the test platform through the first mapping relationship, and then forwarded to the WebSocket server through the second mapping relationship. According to the port forwarding rule, the connection between the target Hongmeng device and the test platform, as well as the connection between the test platform and the WebSocket server are established respectively, so that data can be transmitted normally between the target Hongmeng device, the test platform and the WebSocket server. It should be stated that the port forwarding rule depends on the hardware and software configuration of the target Hongmeng device and the hardware and software configuration of the test platform compatible with the target Hongmeng device, and does not rely on the network to realize the transmission of data and information.

[0067] Furthermore, a method of establishing through the network can also be added to the port forwarding rules. The specific rules are: when the target Hongmeng device accesses a transit port of the test platform through a network request, the request is forwarded to the test port of the WebSocket server through the network, ensuring that the request sent from the Hongmeng device can be correctly forwarded to the transit port of the test platform through the first mapping relationship, and then forwarded to the WebSocket server through the second mapping relationship. It is easy to understand that if the test platform and the target Hongmeng device are in different network environments (such as public and private networks), configure the routing rules of the firewall or router to allow these cross-network communications. The port forwarding rules may vary depending on the network device, but the configuration principles are basically the same. Then, according to the port forwarding rules, use network tools (such as telnet, nc, curl, etc.) or WebSocket clients to try to connect to the transit port of the test platform from the external network to ensure that the connection can be successfully established and that data can be correctly transmitted between the Hongmeng device, the test platform, and the WebSocket server.

[0068] The port forwarding rules set in this embodiment can support the testing of WebSocket servers in non-network environments or network environments at the same time, and can ensure that data can be effectively transmitted between the target Hongmeng device, test platform and WebSocket server.

[0069] Step S300: Based on the port forwarding rule and the first mapping relationship, establish a logical link between the target Hongmeng device and the WebSocket server;

[0070] Specifically, verify whether the port forwarding rules on the test platform are correctly configured and effective, and ensure that the mapping relationship between the transit port and the WebSocket server source port is correct.

[0071] In the offline state, based on the port forwarding rules and the first mapping relationship, the logical link between the target Hongmeng device and the test platform, as well as the logical link between the test platform and the WebSocket server are established respectively. That is, the test platform is regarded as an intermediary, and the logical link relationship between the target Hongmeng device and the WebSocket server is realized through the transit port, so that data or information can be transmitted between the target Hongmeng device and the WebSocket server.

[0072] In the networked state, run a WebSocket client application on the target Hongmeng device, or implement the WebSocket client function through code; configure the WebSocket client to connect to the transit port of the test platform, and map the transit port to the source port of the WebSocket server through the port forwarding rule; the WebSocket client sends a handshake request to the test platform through the configured port, where the handshake request contains the necessary header information and protocol upgrade request to establish a WebSocket connection. After receiving the handshake request, the test platform forwards it to the WebSocket server according to the port forwarding rule. The WebSocket server processes the handshake request and returns a response. The test platform then forwards the handshake response back to the WebSocket client on the Hongmeng device; after receiving the handshake response, the WebSocket client verifies the validity of the response. If the handshake is successful, the WebSocket connection is established, and full-duplex communication can be carried out between the target Hongmeng device and the WebSocket server. It should be stated that when establishing a logical link, the port number, IP address and protocol used should be consistent with the configuration in the port forwarding rule and the first mapping relationship. Furthermore, the WebSocket connection can also be encrypted by TLS / SSL encryption supported by the HDC tool to improve the security of communication.

[0073] In this embodiment, through the above steps, based on the port forwarding rules and the first mapping relationship, a logical link between the target Hongmeng device and the WebSocket server is successfully established, enabling full-duplex communication between the two.

[0074] In a preferred embodiment, the step of establishing a logical link between the target Hongmeng device and the WebSocket server based on the port forwarding rule and the first mapping relationship in step S300 includes:

[0075] Step S310: installing the OpenHarmony HDC tool on the test platform, and starting the port forwarding function of the OpenHarmony HDC tool;

[0076] Step S320: Based on the port forwarding rule, setting the port forwarding parameters of the transit port;

[0077] Step S330: Based on the port forwarding parameters and the first mapping relationship, establish a logical link between the target Hongmeng device and the WebSocket server.

[0078] Specifically, download and install the OpenHarmony HDC tool, and ensure that the installation path of the HDC tool is added to the system's environment variables for easy calling in the command line. Open the HDC command line tool and use the command provided by the HDC tool to start the port forwarding function. In this embodiment, the HDC tool determines the local port of the target Harmony device or the source port of the WebSocket server to be forwarded according to the set port forwarding rules, and uses the port forwarding command in the HDC command line tool to set the parameters of the transit port, including the local port number of the target Harmony device, the transit port number, the IP address of the test platform, and the source port number of the WebSocket server.

[0079] Then configure the WebSocket client on the Hongmeng device, ensure that the WebSocket client is running on the target Hongmeng device, and configure it to connect to the transit port of the test platform; use the port forwarding of the HDC tool to establish a connection. When the WebSocket client on the Hongmeng device tries to connect to the transit port of the test platform, the port forwarding function of the HDC tool will capture this connection request; according to the parameters of the set transit port, the connection request is forwarded to the source port of the WebSocket server through the HDC tool; the WebSocket server processes the connection request and establishes a WebSocket logical connection with the client on the Hongmeng device.

[0080] In this embodiment, through the above steps, the port forwarding function of the OpenHarmony HDC tool is utilized, combined with the port forwarding rules and the parameter settings of the transit port, to quickly and efficiently establish a logical link between the target Hongmeng device and the WebSocket server.

[0081] Step S400: Perform automated testing on the WebSocket server or the target Hongmeng device based on the logical link to generate test results.

[0082] Specifically, first, according to the test objectives, write detailed test cases, where the test objectives are the functions and performance of the WebSocket server, or the compatibility and stability of the target Hongmeng device; ensure that the test platform, HDC tool, WebSocket server and target Hongmeng device are correctly configured and in an available state. Install necessary test tools and frameworks, such as automated test frameworks (such as Selenium, Appium, etc., which may require specific test frameworks for Hongmeng devices), performance testing tools (such as JMeter, LoadRunner, etc.); prepare data for testing, including message content, user information, test parameters, etc.; through the port forwarding function of the HDC tool, ensure that the logical link between the target Hongmeng device and the WebSocket server has been established, and test the stability of the connection, including performance in disconnection and reconnection, network fluctuations, etc. Then, use test cases to perform functional testing, performance testing, and compatibility testing. For functional testing: according to the test cases, test the various functions of the WebSocket server, such as message sending, receiving, heartbeat detection, session management, etc.; or, test the WebSocket client of the target Hongmeng device to verify whether it can correctly parse and process the messages of the WebSocket server. For performance testing: Use performance testing tools to stress test the WebSocket server, simulate a large number of concurrent connections and message transmissions, and evaluate the server's processing capabilities; or test the stability and performance of the target Hongmeng device under long-term operation and large amounts of data transmission. For compatibility testing: Test the compatibility of the target Hongmeng device under different versions and configurations to ensure that the WebSocket client can work properly; or test the compatibility of the WebSocket server with different clients (including Hongmeng devices and other platform clients).

[0083] During the test process, collect and record test data, including response time, error rate, resource usage, etc. Generate a detailed test report based on test data and test cases, including test purpose, test environment, test steps, test results, problem records, etc.

[0084] In this embodiment, based on the established logical links, the above process can be used to perform automated testing on the WebSocket server or target Hongmeng device, and generate accurate and detailed test results, which is conducive to providing strong support for subsequent improvements and optimizations.

[0085] In one embodiment, when the source port of the WebSocket server is tested, the step S400 performs an automated test on the WebSocket server or the target Hongmeng device based on the logical link to generate a test result, including:

[0086] Step S410: Obtain a WebSocket server test script;

[0087] Step S420: Establishing a connection between the server test script and the WebSocket server, and sending first test information to the WebSocket server;

[0088] Step S430: In response to receiving first response information from the WebSocket server to the first test information, compare the first test information with the first response information to generate a test result for the WebSocket server.

[0089] Specifically, according to the established port forwarding rules, the first mapping relationship and the second mapping relationship, a WebSocket server test script is written to ensure that the test script supports the WebSocket protocol and can send and receive messages that comply with the MQTT protocol; the WebSocket client function in the test script is used to establish a connection with the WebSocket server, ensuring that the connection parameters (such as URL, port number) match the configuration of the WebSocket server to establish a WebSocket connection; through the WebSocket connection, a first test message that complies with the MQTT protocol is sent, and the first test message is a publish message containing the MQTT topic, message body and QoS level. The WebSocket server receives a response to the first test message, that is, a first response message. This embodiment uses an asynchronous processing method to extract key content in the first response message, such as the message body, QoS level, etc. The first test message and the first response message are compared to generate a first comparison result, and according to the first comparison result, it is checked whether the WebSocket server has correctly processed the MQTT message, including checking whether the message is successfully delivered, whether the QoS level is complied with, whether the topic matches, etc.

[0090] In this embodiment, the server test script is used to implement the functional test of the MQTT protocol on the WebSocket server, which is beneficial to improving the validity of the test results.

[0091] In one embodiment, when the local port of the target Hongmeng device is tested, the automated testing of the WebSocket server or the target Hongmeng device based on the logical link in step S400 to generate the test result also includes:

[0092] Step S440: Obtain the target Hongmeng device test script;

[0093] Step S450: Establish connections between the device test script and the WebSocket server and the target Hongmeng device respectively, and send second test information to the target Hongmeng device;

[0094] Step S460: In response to receiving the second response information of the target Hongmeng device to the second test information, compare the second test information and the second response information to generate a test result for the target Hongmeng device.

[0095] Specifically, according to the established port forwarding rules, the first mapping relationship, and the second mapping relationship, write a test script for the target Hongmeng device to ensure that the WebSocket server and the target Hongmeng device are correctly configured and accessible. In the test script, use the WebSocket library (such as Python's websockets library) to create a WebSocket client instance, and use the WebSocket client instance to connect to the specified WebSocket server URL. According to the communication protocol of the target Hongmeng device (such as HTTP, TCP / IP, MQTT, etc.), determine the method of establishing a connection with the device; use the corresponding library or API to create a connection instance with the target Hongmeng device; and establish a connection with the target Hongmeng device through the connection instance.

[0096] According to the test requirements, construct the second test information, which contains a JSON object or other format of data packets of test commands and data; send the test information to the WebSocket server through the WebSocket connection, or if communicating directly with the target device, send it through the corresponding connection instance. In the test script, set a waiting mechanism (such as asynchronous waiting, polling, etc.) to receive response information from the target Hongmeng device; receive the second response information through a WebSocket connection or a direct connection with the target device. Parse the received second response information into a comparable format (such as a JSON object), and compare the contents of the second test information and the second response information, such as comparing field values, data structures, etc., to generate test results for the target Hongmeng device, including whether the test passes, error information, etc.

[0097] It is worth noting that, in addition to setting up a method of adding establishment through the network in the port forwarding rules in step S230, the present invention mainly elaborates on other processing steps around the non-network environment. Based on the same concept, the present invention can also realize automated testing of the ports of the target Hongmeng device and WebSocket server in the network environment.

[0098] like Figure 2As shown, corresponding to the above-mentioned automated testing method for Hongmeng devices, an embodiment of the present invention further provides an automated testing system for Hongmeng devices, and the above-mentioned automated testing system for Hongmeng devices includes:

[0099] The information acquisition module 210 is used to create a WebSocket server on the test platform and establish a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmeng device to obtain a first mapping relationship;

[0100] A port forwarding rule construction module 220 is used to establish a physical link between the target Hongmeng device and the test platform, and set a port forwarding rule, wherein the port forwarding rule indicates a forwarding rule between the local port and the source port established through the test platform;

[0101] A logical link establishing module 230, used to establish a logical link between the target Hongmeng device and the WebSocket server based on the port forwarding rule and the first mapping relationship;

[0102] The test module 240 is used to perform automated testing on the WebSocket server or the target Hongmeng device based on the logical link and generate test results.

[0103] Specifically, in this embodiment, the specific functions of the automated testing system for the above-mentioned HarmonyOS devices can also refer to the corresponding description in the automated testing method for the above-mentioned HarmonyOS devices, which will not be repeated here.

[0104] Based on the above embodiments, the present invention further provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 3 As shown. The above-mentioned smart terminal includes a processor, a memory, a network port and a display screen connected via a system bus. Among them, the processor of the smart terminal is used to provide computing and control capabilities. The memory of the smart terminal includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and an automated test program for Hongmeng devices. The internal memory provides an environment for the operation of the operating system in the non-volatile storage medium and the automated test program based on the Hongmeng device. The network port of the smart terminal is used to communicate with an external terminal through a network connection. When the automated test program of the Hongmeng device is executed by the processor, the steps of any of the above-mentioned automated testing methods for the Hongmeng device are implemented. The display screen of the smart terminal may be a liquid crystal display screen or an electronic ink display screen.

[0105] Those skilled in the art will understand that Figure 3The principle block diagram shown in the figure is only a block diagram of a partial structure related to the scheme of the present invention, and does not constitute a limitation on the smart terminal to which the scheme of the present invention is applied. The specific smart terminal may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0106] In one embodiment, a smart terminal is provided, which includes a memory, a processor, and an automated testing program for Hongmeng devices stored in the memory and executable on the processor. When the automated testing program for Hongmeng devices is executed by the processor, the steps of any one of the automated testing methods for Hongmeng devices provided in the embodiments of the present invention are implemented.

[0107] An embodiment of the present invention also provides a computer-readable storage medium, on which an automated testing program for Hongmeng devices is stored. When the automated testing program for Hongmeng devices is executed by a processor, the steps of any automated testing method for Hongmeng devices provided by an embodiment of the present invention are implemented.

[0108] It should be understood that the serial numbers of the steps in the above embodiments do not imply a sequence of execution, and the execution sequence of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0109] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the above-mentioned device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0110] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0111] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0112] In the embodiments provided by the present invention, it should be understood that the disclosed apparatus / terminal equipment and method can be implemented in other ways. For example, the apparatus / terminal equipment embodiments described above are only illustrative, for example, the division of the above modules or units is only a logical function division, and in actual implementation, other division methods can be used, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.

[0113] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, it should be understood by those skilled in the art that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features therein may be replaced by equivalents. However, these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. An automated testing method for Hongmeng devices, characterized in that: The following steps are involved: Create a WebSocket server on the test platform, and establish a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmeng device to obtain a first mapping relationship; Establish a physical link between the target Hongmeng device and the test platform, and set a port forwarding rule, where the port forwarding rule indicates a forwarding rule for establishing the local port and the source port through the test platform; Based on the port forwarding rule and the first mapping relationship, establish a logical link between the target Hongmeng device and the WebSocket server; Based on the logical link, the WebSocket server or the target Hongmeng device is automatically tested to generate test results.

2. The automated testing method for Hongmeng devices according to claim 1 is characterized in that: The establishing of a physical link between the target Hongmeng device and the test platform includes: Pre-install a device driver for the target Hongmeng device; Based on the device driver, a physical link between the target Hongmeng device and the test platform is established.

3. The automated testing method for Hongmeng devices according to claim 1 is characterized in that: The port forwarding rules are set up, including: Set up several transit ports on the test platform; Establishing a mapping relationship between the transit port and the source port of the WebSocket server to obtain a second mapping relationship; A port forwarding rule is set based on the first mapping relationship and the second mapping relationship.

4. The automated testing method for Hongmeng devices according to claim 3 is characterized in that: The establishing of a logical link between the target Hongmeng device and the WebSocket server based on the port forwarding rule and the first mapping relationship includes: Installing the OpenHarmony HDC tool on the test platform and starting the port forwarding function of the OpenHarmony HDC tool; Based on the port forwarding rule, setting the port forwarding parameters of the transit port; Based on the port forwarding parameters and the first mapping relationship, a logical link is established between the target Hongmeng device and the WebSocket server.

5. The automated testing method for Hongmeng devices according to claim 1 is characterized in that: The automated testing of the WebSocket server or the target Hongmeng device based on the logical link to generate a test result includes: Get the WebSocket server test script; Establishing a connection between the server test script and the WebSocket server, and sending first test information to the WebSocket server; In response to receiving first response information from the WebSocket server to the first test information, the first test information and the first response information are compared to generate a test result for the WebSocket server.

6. The automated testing method for Hongmeng devices according to claim 5 is characterized in that: The comparing the first test information and the first response information to generate a first test result includes: Comparing the first test information and the first response information to obtain a first comparison result; The function of the MQTT protocol is verified using the first comparison result to generate a first test result.

7. The automated testing method for Hongmeng devices according to claim 1 is characterized in that: The method of performing automated testing on the WebSocket server or the target Hongmeng device based on the logical link to generate a test result further includes: Get the target Hongmeng device test script; Establish connections between the device test script and the WebSocket server and the target Hongmeng device respectively, and send second test information to the target Hongmeng device; In response to receiving the second response information of the target Hongmeng device to the second test information, the second test information and the second response information are compared to generate a test result for the target Hongmeng device.

8. An automated testing system for Hongmeng devices, characterized in that: The system comprises: An information acquisition module is used to create a WebSocket server on the test platform and establish a mapping relationship between the source port of the WebSocket server and the local port of the target Hongmeng device to obtain a first mapping relationship; A port forwarding rule construction module, used to establish a physical link between the target Hongmeng device and the test platform, and set a port forwarding rule, wherein the port forwarding rule indicates a forwarding rule between the local port and the source port established through the test platform; A logical link establishment module, used to establish a logical link between the target Hongmeng device and the WebSocket server based on the port forwarding rule and the first mapping relationship; A testing module is used to perform automated testing on the WebSocket server or the target Hongmeng device based on the logical link and generate test results.

9. An intelligent terminal, characterized in that: The smart terminal includes a memory, a processor, and an automated testing program for Hongmeng devices stored in the memory and executable on the processor. When the automated testing program for Hongmeng devices is executed by the processor, the steps of the automated testing method for Hongmeng devices as described in any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an automated testing program for Hongmeng devices, and when the automated testing program for Hongmeng devices is executed by the processor, the steps of the automated testing method for Hongmeng devices as described in any one of claims 1 to 7 are implemented.