Interface testing method, system, terminal and medium for connecting multiple Hongmeng devices
By providing an interface testing method that connects multiple Hongmenghua devices, and using target test scripts to identify and connect devices, the problem of not being able to achieve multi-device automated testing in the prior art is solved, and efficient and flexible testing results are achieved.
Patent Information
- Application Number
- CN202411631702.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-02-07
- Estimated Expiration
- 2044-11-15
AI Technical Summary
In the prior art, it is impossible to use test scripts written based on DevEco Studio to automatically test multiple Hongmenghua devices, resulting in manual operations to connect multiple devices.
Provide an interface testing method for connecting multiple Hongmenghua devices, and by receiving target testing scripts, identifying and connecting target Hongmenghua devices, and generating test reports. The method includes registering a device interface, determining the device connection sequence, establishing a device connection using WebSocket information, and receiving status change information in real time to generate a test report.
Automatic testing of multiple Hongmenghua devices has been realized, which improves the real-time and accuracy of the test, and enhances the flexibility and scalability of the test.
Smart Images

Figure CN119127723B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of Hongmeng device testing technology, and in particular to an interface testing method, system, terminal and medium for connecting multiple Hongmeng devices. Background Art
[0002] DevEco Studio, the development editor for HarmonyOS native applications, is an integrated development environment for HarmonyOS application and meta-service developers. Currently, test scripts written based on DevEco Studio can only run on one HarmonyOS device, resulting in the need to use multiple HarmonyOS devices for testing Application Programming Interface (API), referred to as API interface, which can only be tested manually and cannot be automated. For example, the connection of Bluetooth needs to be achieved through two HarmonyOS devices, one HarmonyOS device is used to turn on Bluetooth, and the other HarmonyOS device is used to connect to the Bluetooth. However, the test scripts written based on DevEco Studio can only connect to one of the HarmonyOS devices, and the connection of other HarmonyOS devices requires manual operation.
[0003] It can be seen that in the prior art, for API interfaces that need to connect to multiple Hongmeng devices for testing, there is a defect that it is impossible to use test scripts written based on DevEco Studio to achieve automated testing of multiple Hongmeng devices. Summary of the invention
[0004] In view of the above-mentioned deficiencies in the prior art, the object of the present invention is to provide an interface testing method, system, terminal and medium for connecting multiple Hongmeng devices, aiming to solve the problem in the prior art that it is impossible to use test scripts written based on DevEco Studio to realize automated testing of multiple Hongmeng devices.
[0005] In order to achieve the above object, the first aspect of the present invention provides an interface testing method for connecting multiple Hongmeng devices, comprising:
[0006] Receive a target test script, where the target test script is used to reflect the process of testing one or more target test interfaces by connecting multiple target Hongmeng devices;
[0007] Based on the test process of the target test script, identify and connect the corresponding target Hongmeng device;
[0008] Generate a test report based on the interaction between all the target Hongmeng devices and the target test interface.
[0009] Optionally, before receiving the target test script, the method further includes:
[0010] Register a test interface that corresponds one-to-one with the interfaces of all the target Hongmeng devices.
[0011] Optionally, the test process based on the target test script identifies and connects the corresponding target Hongmeng device, including:
[0012] Based on the test flow of the target test script, determine all target Hongmeng devices and the test connection order;
[0013] Based on the connection order, the corresponding target Hongmeng devices are identified and connected in sequence through the target test interface.
[0014] Optionally, based on the connection order, sequentially identifying and connecting corresponding target Hongmeng devices through the target test interface includes:
[0015] Obtain the product identifications of all the target Hongmeng devices;
[0016] Based on the connection order and the product identifier, send WebSocket information to a prior target Hongmeng device among the target Hongmeng devices, and receive a parsing result of the WebSocket information fed back by the prior target Hongmeng device;
[0017] According to the analysis result, connect the corresponding subsequent target Hongmeng device in the target Hongmeng device.
[0018] Optionally, before receiving the parsing result of the WebSocket information fed back by the prior target Hongmeng device, the method includes:
[0019] Based on the WebSocket information, establish a WebSocket connection between the prior target Hongmeng device and the target test interface;
[0020] Based on the WebSocket connection, receive the status change information sent by the prior target Hongmeng device and the analysis results of the WebSocket information.
[0021] Optionally, the generating of a test report based on the interaction between all the target Hongmeng devices and the target test interface includes:
[0022] Receive the status change information of the prior target Hongmeng device through the target test interface and send it to the subsequent target Hongmeng device;
[0023] Receive the test result fed back by the subsequent target Hongmeng device, and refresh the status of the prior target Hongmeng device;
[0024] Repeat the actions of receiving test results and refreshing the target Hongmeng devices until the test results fed back by all the target Hongmeng devices are received and a test report is generated.
[0025] A second aspect of the present invention provides an interface testing device for connecting multiple Hongmeng devices, the system comprising:
[0026] An information acquisition module, used to receive a target test script, where the target test script is used to reflect the process of testing one or more target test interfaces by connecting multiple target Hongmeng devices;
[0027] A target Hongmeng device connection module is used to identify and connect the corresponding target Hongmeng device based on the test process of the target test script;
[0028] A test module is used to generate a test report based on the interaction between all the target Hongmeng devices and the target test interface.
[0029] Optionally, the target HarmonyOS device connection module includes a connection preparation unit and a connection unit, wherein the connection preparation unit is used to determine all target HarmonyOS devices and test connection sequence based on the test process of the target test script; and the connection unit is used to identify and connect corresponding target HarmonyOS devices in sequence through the target test interface based on the connection sequence.
[0030] The third aspect of the present invention provides a smart terminal, which includes a memory, a processor, and an interface testing program for connecting multiple Hongmeng devices stored in the memory and runnable on the processor. When the interface testing program for connecting multiple Hongmeng devices is executed by the processor, any step of the above-mentioned interface testing method for connecting multiple Hongmeng devices is implemented.
[0031] A fourth aspect of the present invention provides a computer-readable storage medium, on which is stored an interface testing program for connecting multiple Hongmeng devices. When the interface testing program for connecting multiple Hongmeng devices is executed by a processor, the interface testing program for connecting multiple Hongmeng devices implements any step of the above-mentioned interface testing method for connecting multiple Hongmeng devices.
[0032] Compared with the prior art, the beneficial effects of this solution are as follows:
[0033] The present invention mainly provides a test platform for API interfaces that need to connect to multiple devices for testing. The test platform is used to connect and control multiple Hongmeng devices, so that different steps of the target programming language test script are run on different devices, and multiple devices are connected, thereby achieving the automated testing effect of the API interface in such scenarios. At the same time, the method successfully establishes a WebSocket connection between the first target Hongmeng device and the target test interface, and receives state change information and analysis results in real time, which can not only effectively improve the real-time and accuracy of the test, but also help to enhance the flexibility and scalability of the test. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] 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.
[0035] Figure 1 This is a flow chart of the interface testing method for connecting multiple Hongmeng devices of the present invention;
[0036] Figure 2 This is a schematic diagram of the interface test system module for connecting multiple Hongmeng devices of the present invention;
[0037] Figure 3 It is a schematic diagram of the structure of the intelligent terminal of the present invention. DETAILED DESCRIPTION
[0038] 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.
[0039] 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.
[0040] 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.
[0041] It should be further understood that the term "and / or" used in the present description and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0042] 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.
[0043] 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.
[0044] 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.
[0045] The present invention aims at the problem that the API interface in the prior art needs to connect to multiple Hongmeng devices for testing, and it is impossible to use the test script written based on DevEco Studio to realize the automated testing of multiple Hongmeng devices. An interface testing method for connecting multiple Hongmeng devices is proposed. It is mainly aimed at the API interface that needs to connect to multiple devices for testing, and a test platform is provided. The test platform is used to connect and control multiple devices, so that different steps of the target programming language test script are run on different devices, and the connection of multiple devices is realized, thereby realizing the automated testing effect of the API interface in such scenarios. For example, for the test of Bluetooth connection, it can achieve the test effect of first connecting a device to turn on Bluetooth, and then connecting another device to connect to the Bluetooth.
[0046] The embodiment of the present invention provides an interface testing method for connecting multiple Hongmeng devices, which is deployed on electronic devices such as computers and servers, and is applied to the scenario of implementing API interface testing of Hongmeng devices on a test platform built based on the HarmonyOS system, and is aimed at connecting multiple Hongmeng devices to test the API interface. Specifically, Figure 1 As shown, the steps of the method in this embodiment include:
[0047] Step S100: receiving a target test script, where the target test script is used to reflect the process of testing one or more target test interfaces by connecting multiple target Hongmeng devices;
[0048] Specifically, before receiving the target test script, count all target Hongmeng devices that need to be called in the target test script, and register the test interface that corresponds to the interface of all target Hongmeng devices in the test platform to ensure that the API interface in the test platform meets the requirements for integrity testing of the target test interface. Among them, Hongmeng devices refer to hardware devices with processing and response capabilities installed with the HarmonyOS system, such as smart home devices, Internet of Things devices, etc. The test platform can be any type of computer, such as a laptop, desktop, etc.
[0049] After the test interface in the test platform is configured, design the target test script. The specific process is as follows: First, by understanding the functions, features, interfaces, etc. of the target Hongmeng device in detail, ensure that the test script can be called accurately; clarify the purpose and scope of the test, including the functional points and performance indicators corresponding to the target test interface to be tested; build a test environment compatible with the HarmonyOS system and Hongmeng devices, that is, the test platform. Then, according to the test objectives, select representative test cases to ensure that the main functions and features are covered; design clear test steps for each test case, including device connection, data input, result verification, etc.; prepare corresponding test data according to the test case to ensure the accuracy and completeness of the data. Finally, according to the requirements of the test platform, write the test script using a programming language that is compatible with the DevEco Studio development tool (such as Python, Java, JS, and CC++); write the test script code according to the test steps, including device identification, connection, data transmission, result reception, etc. Add appropriate comments to the code to improve the readability of the code. At the same time, add an error handling mechanism to deal with possible abnormal situations. Furthermore, the test script can also be debugged and verified, mainly in the test environment to ensure that the script can correctly identify and connect to the target Hongmeng device, and can execute the test steps as expected. Verify the correctness and effectiveness of the test script by comparing the expected results with the actual results. In summary, the target test script is a test script edited in the target programming language according to the functions, performance and other test tasks corresponding to the target test interface that needs to be tested. It is used to reflect the process of testing one or more target test interfaces by connecting multiple target Hongmeng devices. The target test interface specifically refers to an independent target test interface or multiple functionally related target test interfaces.
[0050] Then, after editing and generating the target test script, the target test script is uploaded to the test platform, and the target test script is subsequently run through the test platform.
[0051] Step S200: Based on the test process of the target test script, identify and connect the corresponding target Hongmeng device;
[0052] Specifically, based on the test process of the target test script, the test platform identifies and connects one or more target test interfaces corresponding to the target test script and multiple target Hongmeng devices that need to be called, so as to utilize the test platform to connect and control multiple target Hongmeng devices, so that different steps of the test script run on different target Hongmeng devices, thereby realizing the calling and control of multiple target Hongmeng devices.
[0053] Step S300: Generate a test report based on the interaction between all the target Hongmeng devices and the target test interface.
[0054] Specifically, use the device discovery function provided by the HarmonyOS system, obtain the current list of surrounding devices through the DeviceManager class, obtain the device information that needs to be interacted from the device list, use the Device class to establish a connection with the target device, use the established connection to send messages to the target device, and receive the connection request and process the message in the target device. Record the execution of test cases, detailed information on errors and defects, and performance and stability data. Archive the execution results of test cases, and classify errors and defects according to different types, severity, and priorities. Compare the actual test results with the expected results, analyze the causes of errors and defects, and evaluate performance and stability.
[0055] Finally, write a test report based on the test results, specifically: briefly introduce the purpose and scope of the test; describe the execution and results of the test cases, including the number of passed cases, the number of failed cases, and the number of unexecuted cases; compare the actual test results with the expected results, list the errors and defects found, including a detailed description of the errors, reproduction steps and priority, and analyze the causes of the errors and defects; evaluate and analyze performance and stability data; summarize the test results, and put forward suggestions for improvement and optimization, etc.
[0056] In this embodiment, by building a test platform compatible with the HarmonyOS system and Hongmeng devices, and using a programming language adapted to the DevEco Studio development tool, a target test script is written according to the target test interface, so that the corresponding target Hongmeng device is identified and called based on the target test script, and the calling and control of multiple target Hongmeng devices are realized, thereby achieving the automated testing effect of the API interface in the HarmonyOS system that needs to connect multiple Hongmeng devices for testing, which is conducive to simplifying the operation steps and significantly improving the testing efficiency.
[0057] In a preferred embodiment, the test process based on the target test script in step S200 identifies and connects the corresponding target Hongmeng device, including:
[0058] Step S210: Determine all target Hongmeng devices and the test connection order based on the test process of the target test script;
[0059] Step S220: Based on the connection order, identify and connect the corresponding target Hongmeng devices in sequence through the target test interface.
[0060] Specifically, based on the test process of the target test script, all target Hongmeng devices that need to be tested are determined through device model, version, configuration and other information, and it is determined whether there are dependencies between devices. For example, some devices need to be slave devices of other devices or require a specific connection order. According to the dependencies between devices and test requirements, a test connection order is formulated to ensure that before connecting each device, the devices it depends on are connected and in an available state.
[0061] Then, ensure that the test platform or test tool has installed the necessary drivers and test interfaces, and ensure that the test platform or test tool is compatible with the target Hongmeng device so that it can identify and connect to the Hongmeng device. According to the established test connection sequence, use the test interface to identify the target Hongmeng device in turn. The device can be identified by the device's unique identifier (such as device ID, MAC address, product serial number, etc.). Before connecting the device, ensure that the target Hongmeng device is in a usable state, such as turned on, unlocked, and installed with necessary test applications. Establish a connection between the test interface and the target Hongmeng device by entering the device's connection parameters, such as IP address, port number, authentication information, etc. During the device connection process, set a reasonable connection timeout to avoid connection failures due to slow device response or network delays. After the connection is established, verify whether the device's connection status is stable, and check whether the device has been correctly identified and connected to the test platform. Record the connection information of each device, including connection time, connection status, device information, etc., for subsequent analysis and troubleshooting.
[0062] In this embodiment, through the above steps, it can be ensured that the test process based on the target test script can successfully identify and connect all target Hongmeng devices, and perform tests according to the predetermined test connection order.
[0063] In a preferred embodiment, the step S220 of sequentially identifying and connecting corresponding target Hongmeng devices through the target test interface based on the connection order includes:
[0064] Step S221: Obtain product identifications of all the target Hongmeng devices;
[0065] Specifically, use the device discovery function provided by the Harmony system to obtain the device's IP address, device name, product identification (such as device ID or model) and other information through the local area network (LAN) or wide area network (WAN) to identify the available Harmony devices around, thereby obtaining the product identification of all target Harmony devices. The product identification refers to the unique code or name assigned by the device manufacturer to each device, which is used to distinguish different device models or configurations, such as product serial number, device ID, etc.
[0066] Step S222: Based on the connection order and the product identifier, send WebSocket information to a previous target Hongmeng device among the target Hongmeng devices, and receive a parsing result of the WebSocket information fed back by the previous target Hongmeng device;
[0067] Specifically, according to the connection order, first try to establish a WebSocket connection with the target Hongmeng device that ranks first. WebSocket is a network communication protocol that allows full-duplex communication over a single TCP connection. This means that information can flow bidirectionally between the device and the PC. WebSocket information usually includes specific data or instructions, which are sent by the PC to the target device. WebSocket connection is often used for real-time communication because it allows a persistent connection to be established between the client and the server, and messages are sent and received through the connection. After the WebSocket connection is established, a WebSocket message containing a product identification and connection instructions is sent to the device. The message can be a JSON object containing the product identification of the target device, the connection request type, necessary authentication information (such as a token or password), etc. Wait for and receive the WebSocket message returned by the target Hongmeng device, which should contain the parsing result of the previously sent information. The parsing result may be a simple confirmation message indicating that the device has successfully understood and processed the connection request; or, it may contain more detailed error information indicating the reason for the connection failure.
[0068] Step S223: Connect the corresponding subsequent target Hongmeng device in the target Hongmeng device according to the analysis result.
[0069] Specifically, the test platform parses the WebSocket message received from the previous target Hongmeng device to confirm whether the connection request is successful. If the connection is successful, proceed to the next step; if the connection fails, take corresponding error handling measures according to the error information (such as retrying the connection, updating device information, recording error logs, etc.). According to the connection sequence and product identification, repeat the above steps to establish WebSocket connections with subsequent target Hongmeng devices in turn. At each connection stage, ensure that the current device has been successfully connected and is ready to receive connection requests from subsequent devices.
[0070] During the entire connection process, the status of all connected devices is continuously monitored. If any device is found to be disconnected or exhibiting abnormal behavior, appropriate recovery measures should be taken immediately to ensure the continuity and reliability of the test.
[0071] In this embodiment, through the above steps, it can be ensured that WebSocket information is successfully sent to the target Hongmeng device based on the connection order and product identification, and the corresponding device is connected according to the analysis results, which can not only improve the accuracy of the connection, but also effectively enhance the flexibility and scalability of the test.
[0072] In a preferred embodiment, before receiving the parsing result of the WebSocket information fed back by the prior target Hongmeng device, step S222 includes:
[0073] Step S224: Building a WebSocket connection between the prior target Hongmeng device and the target test interface based on the WebSocket information;
[0074] Step S225: Based on the WebSocket connection, receive the status change information sent by the prior target Hongmeng device and the analysis result of the WebSocket information.
[0075] Specifically, on the target test interface side, prepare a WebSocket client library (such as Java's java-websocket, Python's websockets, or JavaScript's WebSocket API, etc.). Configure the WebSocket client, including setting the URL to be connected (the WebSocket service address of the first target Hongmeng device), necessary authentication information (such as tokens, passwords, etc.), and connection timeout and other parameters, and use the WebSocket client to initiate a connection request to the first target Hongmeng device. For example, send an HTTP-style handshake request that contains the upgrade header information of the WebSocket protocol. After the first target Hongmeng device receives the handshake request, if the verification is successful, it will return a response containing the same WebSocket protocol upgrade header information. After receiving this response, the WebSocket client will complete the handshake process and establish a persistent WebSocket connection.
[0076] After the WebSocket connection is established, a callback function or event listener is registered on the WebSocket client, and the target test interface continuously listens to the messages on the connection so that new messages can be processed when they are received. When the state of the first target Hongmeng device changes (such as device startup, shutdown, configuration update, etc.), it will send the state change information to the target test interface through the WebSocket connection. After receiving this information, the target test interface parses and processes it to update the internal state or trigger the corresponding test logic. For the previously sent WebSocket information (such as connection requests, configuration instructions, etc.), the first target Hongmeng device will send the parsing results as a response. After receiving these parsing results, the target test interface checks whether these parsing results indicate successful processing or contain error information. If the parsing result indicates successful processing, you can continue with subsequent operations (such as connecting to subsequent devices, sending more instructions, etc.). If the parsing result contains error information, the corresponding error handling measures should be taken according to the error type (such as retrying the connection, recording error logs, sending alarms, etc.).
[0077] During the entire test process, the target test interface should continuously monitor the stability of the WebSocket connection. If the connection is disconnected or abnormal behavior (such as connection timeout, message loss, etc.) is found, appropriate recovery measures (such as reconnection, sending heartbeat messages, etc.) should be taken immediately to ensure the continuity and reliability of the test.
[0078] For example, for each called interface, if the call fails, the call is repeated or a fault prompt message is issued; if a certain interface call is successful, when the first target Hongmeng device is successfully logged in, the system confirms that the device is authorized and trusted, so a WebSocket connection is generated for the first target Hongmeng device. WebSocket is a protocol for full-duplex communication on a single TCP connection. Unlike the "request-response" model of HTTP, WebSocket allows data exchange between the server and the client to become more real-time and bidirectional. The WebSocket connection allows continuous, low-latency data exchange between the first target Hongmeng device and the server, which is essential for applications that require real-time updates (such as location tracking, real-time communication, etc.). Whenever certain events occur on the first target Hongmeng device (such as online, location update, offline, etc.), it sends text messages to the server through the previously established WebSocket connection. These messages usually contain the type of event (for example, "location_update") and related data (for example, new latitude and longitude coordinates) to allow the server to understand the status of the first target Hongmeng device in real time and respond accordingly.
[0079] The first target Hongmeng device sends a text message, and the WebSocket service on the server receives the message from the first target Hongmeng device, and parses and processes it according to the content of the message (especially the event type), so that the server can trigger the corresponding logic by identifying and processing the message, such as updating the device status in the database, calculating new location information, etc. Then, based on the message sent by the first target Hongmeng device, the server needs to send real-time messages to one or more subsequent target Hongmeng devices (for example, other mobile devices, desktop applications, or IoT devices). These messages may contain updated information (such as new locations) so that the subsequent target Hongmeng devices can understand the status changes of the first target Hongmeng device in real time and respond accordingly (for example, update the displayed location information). When processing the message sent by the first target Hongmeng device, the server may also need to send test results or status updates to the test platform (for example, a monitoring console or data analysis application). These test results may include verifying the validity of the data sent by the first target Hongmeng device, the accuracy of the calculated new location information, etc. The entire process is achieved through the collaborative work between multiple components, including the first target Hongmeng device, the server, the subsequent target Hongmeng device, and the test platform.
[0080] After each subsequent target Hongmeng device receives the real-time message sent by the previous target Hongmeng device, it identifies the corresponding event of the previous target Hongmeng device, completes the status update such as the location refresh of the previous target Hongmeng device, and returns its test results to the test platform. WebSocket can maintain a persistent connection and continuously send and receive data without establishing a new connection for each message, realizing real-time communication, remote control or other scenarios that require real-time data exchange between the device and the PC.
[0081] It should be noted that the subsequent target Hongmeng device refers to all target devices that need to be connected during the test of the interface except the prior target Hongmeng device, but different subsequent target Hongmeng devices may need to be connected depending on the status of the prior target Hongmeng device. If the subsequent target Hongmeng device needs to send real-time messages to other target devices, the working principle of the subsequent target Hongmeng device is the same as that of the prior target Hongmeng device.
[0082] This embodiment can ensure the successful establishment of a WebSocket connection between the target Hongmeng device and the target test interface, and receive status change information and analysis results in real time, which can not only effectively improve the real-time and accuracy of the test, but also help to enhance the flexibility and scalability of the test.
[0083] In a preferred embodiment, the step S300 of generating a test report based on the interaction between all the target Hongmeng devices and the target test interface includes:
[0084] Step S310: receiving the state change information of the previous target Hongmeng device through the target test interface and sending it to the subsequent target Hongmeng device;
[0085] Step S320: receiving the test result fed back by the subsequent target Hongmeng device, and refreshing the status of the prior target Hongmeng device;
[0086] Step S330: Repeat the actions of receiving test results and refreshing the target Hongmeng devices until the test results fed back by all the target Hongmeng devices are received and a test report is generated.
[0087] Specifically, the target test interface continuously monitors the WebSocket connection established with the previous target Hongmeng device in order to receive status change information in a timely manner. When receiving status change information, the target test interface parses this information to understand the current status of the previous target Hongmeng device. According to the test process or preset rules, the target test interface forwards the parsed status change information to the subsequent target Hongmeng device, which can be achieved by sending the WebSocket message again or calling other communication interfaces.
[0088] After receiving the state change information, the subsequent target Hongmeng device executes the corresponding test logic and sends the test results back to the target test interface through a WebSocket connection or other communication methods; the target test interface receives and parses the test results to understand the response and test results of the subsequent target Hongmeng device to the state change information; based on the test results, the target test interface updates the state information of the prior target Hongmeng device, such as modifying internal state records, updating database entries, or displaying the new state to the user interface.
[0089] The target test interface repeats the above steps, receives the test results of each target Hongmeng device in turn, and refreshes the corresponding device status. During the entire test process, the target test interface continuously monitors the status changes of all devices to ensure that the tests can be executed in sequence and accurately. When all target Hongmeng devices have fed back the test results, the target test interface collects these test results and generates a detailed test report. The test report contains information such as the test results, status change history, test timestamp, possible error information and recommended repair measures for each device. Furthermore, the target test interface stores the generated test report to a specified location (such as a local file system, cloud storage or database, etc.). According to actual application needs, the test report is shared with relevant technical personnel through e-mail and other means for subsequent monitoring and maintenance work.
[0090] In this embodiment, through the above steps, it can be ensured that the target test interface can receive and process the state change information and test results of the target Hongmeng device, and finally generate a comprehensive and accurate test report, which can not only effectively improve the degree of test automation, but also significantly enhance the reliability and traceability of the test.
[0091] like Figure 2 As shown, corresponding to the above-mentioned interface testing method for connecting multiple Hongmeng devices, an embodiment of the present invention further provides an interface testing device for connecting multiple Hongmeng devices, and the above-mentioned interface testing device for connecting multiple Hongmeng devices includes:
[0092] An information acquisition module 210 is used to receive a target test script, where the target test script is used to reflect the process of testing one or more target test interfaces by connecting multiple target Hongmeng devices;
[0093] A target Hongmeng device connection module 220 is used to identify and connect a corresponding target Hongmeng device based on the test process of the target test script;
[0094] The test module 230 is used to generate a test report based on the interaction between all the target Hongmeng devices and the target test interface.
[0095] Furthermore, the target HarmonyOS device connection module includes a connection preparation unit and a connection unit, wherein the connection preparation unit is used to determine all target HarmonyOS devices and test connection sequence based on the test process of the target test script; and the connection unit is used to identify and connect the corresponding target HarmonyOS devices in sequence through the target test interface based on the connection sequence.
[0096] Specifically, in the present embodiment, the specific functions of the interface testing device for connecting multiple Hongmeng devices can also refer to the corresponding description in the interface testing method for connecting multiple Hongmeng devices, which will not be repeated here.
[0097] Based on the above embodiments, the present invention further provides an intelligent terminal, whose principle block diagram can be shown as follows: Figure 3As shown. The above-mentioned smart terminal includes a processor, a memory, a network interface 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 interface test program for connecting multiple Hongmeng devices. The internal memory provides an environment for the operation of the operating system in the non-volatile storage medium and the interface test program based on connecting multiple Hongmeng devices. The network interface of the smart terminal is used to communicate with an external terminal through a network connection. When the interface test program for connecting multiple Hongmeng devices is executed by the processor, the steps of any of the above-mentioned interface test methods for connecting multiple Hongmeng devices are implemented. The display screen of the smart terminal may be a liquid crystal display screen or an electronic ink display screen.
[0098] Those skilled in the art will understand that Figure 3 The 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.
[0099] In one embodiment, a smart terminal is provided, which includes a memory, a processor, and an interface testing program for connecting multiple Hongmeng devices that is stored in the memory and can be run on the processor. When the interface testing program for connecting multiple Hongmeng devices is executed by the processor, the steps of any one of the interface testing methods for connecting multiple Hongmeng devices provided in an embodiment of the present invention are implemented.
[0100] An embodiment of the present invention also provides a computer-readable storage medium, on which is stored an interface testing program for connecting multiple Hongmeng devices. When the interface testing program for connecting multiple Hongmeng devices is executed by a processor, the steps of any one of the interface testing methods for connecting multiple Hongmeng devices provided in an embodiment of the present invention are implemented.
[0101] 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.
[0102] 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.
[0103] 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.
[0104] 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.
[0105] 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.
[0106] 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. A method for testing an interface connecting multiple Hongmeng devices, characterized in that: The test platform used for compatible HarmonyOS system and Hongmeng devices, as well as the programming language adapted to the DevEco Studio development tool, includes the following steps: Receive a target test script, where the target test script is used to reflect the process of testing one or more target test interfaces by connecting multiple target Hongmeng devices; Based on the test process of the target test script, identify and connect the corresponding target Hongmeng device; Generate a test report based on the interaction between all the target Hongmeng devices and the target test interface; The test process based on the target test script identifies and connects the corresponding target Hongmeng device, including: Based on the test process of the target test script, all target Hongmeng devices that need to be tested are determined by device model, version and configuration information; and a connection sequence is formulated according to the dependencies and test requirements between the target Hongmeng devices; based on the connection sequence, the corresponding target Hongmeng devices are sequentially identified and connected through the target test interface; Based on the connection sequence, sequentially identifying and connecting corresponding target Hongmeng devices through the target test interface includes: Obtain the product identifications of all the target Hongmeng devices; based on the connection order and the product identification, send WebSocket information to the prior target Hongmeng device among the target Hongmeng devices; based on the WebSocket information, establish a WebSocket connection between the prior target Hongmeng device and the target test interface; based on the WebSocket connection, receive the state change information sent by the prior target Hongmeng device and the parsing result of the WebSocket information; connect the corresponding subsequent target Hongmeng device in the target Hongmeng devices according to the parsing result; in the process of connecting the devices, set the connection timeout; after establishing the connection, verify whether the connection status of the device is stable, and check whether the device has been correctly identified and connected to the test platform; The method of receiving the state change information sent by the prior target Hongmeng device and the parsing result of the WebSocket information based on the WebSocket connection; and connecting the corresponding subsequent target Hongmeng device in the target Hongmeng device according to the parsing result, includes: The first target Hongmeng device sends a text message, and the WebSocket service on the server receives the message from the first target Hongmeng device, and parses and processes it according to the content of the message; then based on the message sent by the first target Hongmeng device, the server sends a real-time message to one or more subsequent target Hongmeng devices; after each subsequent target Hongmeng device receives the real-time message sent by the first target Hongmeng device, it identifies the corresponding event of the first target Hongmeng device, executes the status update of the first target Hongmeng device, and returns its test results to the test platform; The generating of a test report based on the interaction between all the target Hongmeng devices and the target test interface includes: Use the device discovery function provided by the HarmonyOS system to obtain the list of available HarmonyOS devices around through the DeviceManager class, obtain the device information that needs to be interacted with from the list of HarmonyOS devices, use the Device class to establish a connection with the target HarmonyOS device, use the established connection to send messages to the target HarmonyOS device, and receive the connection request and process the message in the target HarmonyOS device.
2. The interface testing method for connecting multiple Hongmeng devices according to claim 1 is characterized in that: Before receiving the target test script, the following steps are included: Register a test interface that corresponds one-to-one with the interfaces of all the target Hongmeng devices.
3. The interface testing method for connecting multiple Hongmeng devices according to claim 1 is characterized in that: The generating of a test report based on the interaction between all the target Hongmeng devices and the target test interface includes: Receive the status change information of the prior target Hongmeng device through the target test interface and send it to the subsequent target Hongmeng device; Receive the test result fed back by the subsequent target Hongmeng device, and refresh the status of the prior target Hongmeng device; Repeat the actions of receiving test results and refreshing the target Hongmeng devices until the test results fed back by all the target Hongmeng devices are received and a test report is generated.
4. An interface testing device connecting multiple Hongmeng devices, characterized in that: The device is applied to implement the steps of the interface testing method for connecting multiple Hongmeng devices as described in any one of claims 1 to 3, and includes: An information acquisition module, used to receive a target test script, where the target test script is used to reflect the process of testing one or more target test interfaces by connecting multiple target Hongmeng devices; A target Hongmeng device connection module is used to identify and connect the corresponding target Hongmeng device based on the test process of the target test script; A test module is used to generate a test report based on the interaction between all the target Hongmeng devices and the target test interface.
5. The interface testing device for connecting multiple Hongmeng devices according to claim 4 is characterized in that: The target Hongmeng device connection module includes a connection preparation unit and a connection unit, wherein: The connection preparation unit is used to determine all target Hongmeng devices and the test connection order based on the test process of the target test script; The connection unit is used to identify and connect the corresponding target Hongmeng device in sequence through the target test interface based on the connection order.
6. An intelligent terminal, characterized in that: The smart terminal includes a memory, a processor, and an interface testing program for connecting multiple Hongmeng devices that is stored in the memory and can be run on the processor. When the interface testing program for connecting multiple Hongmeng devices is executed by the processor, the steps of the interface testing method for connecting multiple Hongmeng devices as described in any one of claims 1-3 are implemented.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an interface testing program for connecting multiple Hongmeng devices. When the interface testing program for connecting multiple Hongmeng devices is executed by the processor, the steps of the interface testing method for connecting multiple Hongmeng devices as described in any one of claims 1-3 are implemented.
Citation Information
Patent Citations
Serial port test method and device, equipment and storage medium
CN116846801A