A test method, system and electronic device based on OpenHarmony applications

By generating test scripts using cross-platform scripting tools and the OpenHarmony command line, and combining distributed connection technology, the efficiency and effectiveness issues in OpenHarmony application testing are resolved. This enables simultaneous testing on multiple devices and ensures stability, making it suitable for stress testing of acquiring application scenarios in the financial sector.

CN117827657BActive Publication Date: 2025-11-07FUJIAN LANDI COMMERCIAL EQUIPMENT CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311872109.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-11-07
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

Existing technologies for OpenHarmony application testing in OpenHarmony systems suffer from low testing efficiency and poor testing results. In particular, they are inconvenient to write test scripts, cannot run a specified number of times stably, do not support simultaneous testing on multiple devices, cannot support all input events, and cannot record memory information simultaneously.

Method used

The test scripts were generated using a cross-platform scripting tool via the OpenHarmony command line. PowerShell and HDC uinput commands were used to simulate user input, ensure stability, enable simultaneous operation of multiple devices, and record memory information. The test was conducted in conjunction with distributed connection technology.

Benefits of technology

It improves the testing efficiency and effectiveness of OpenHarmony applications, meets the stress testing needs of acquiring applications in the financial sector, and solves the problems of low testing efficiency and poor results in existing technologies.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117827657B_ABST
    Figure CN117827657B_ABST
Patent Text Reader

Abstract

The application discloses a test method and system based on an OpenHarmony application and electronic equipment, and the test script is generated through an OpenHarmony command line by using a cross-platform script tool, wherein the hdc command tool can simulate user input, thereby avoiding the limitation of the OpenHarmony automatic test framework scheme that needs to be written in DevEco. The PowerShell script can ensure high stability and meet the current test frequency requirements. Meanwhile, the hdc command tool supports specifying the target device of the command through parameters, and in combination with PowerShell, the PC can simultaneously operate multiple devices; and the hdc command tool can realize full event input and memory information return, and in combination with PowerShell, the memory information can be recorded to a file to realize memory information recording in the running process. Therefore, the pressure test of the transaction scene of the collecting application is met, and the problems of low test efficiency and poor test effect are solved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of financial application testing, and in particular to a test method and system based on OpenHarmony applications and electronic equipment. BACKGROUND

[0002] With the continuous development of financial digital service terminals and the increasing demand for localization, more and more financial terminals will choose to use a system based on the OpenHarmony platform.

[0003] However, the current OpenHarmony application testing of the OpenHarmony system has the problems of low testing efficiency and poor testing effect. SUMMARY

[0004] The technical problem to be solved by the present application is to provide a test method and system based on OpenHarmony applications and electronic equipment to solve the problems of low testing efficiency and poor testing effect.

[0005] To solve the above technical problems, the technical solution adopted by the present application is:

[0006] A test method based on OpenHarmony applications, characterized by a test terminal for testing OpenHarmony applications on a to-be-tested terminal, the test terminal being connected to at least one to-be-tested terminal, the method comprising:

[0007] Obtaining application information of a to-be-tested application, the to-be-tested application being an OpenHarmony application;

[0008] Polling a target to-be-tested terminal, the target to-be-tested terminal including a to-be-tested terminal connected to the test terminal;

[0009] Obtaining a test item input by a user, the test item including a test script, the test script being generated by a cross-platform script tool through an OpenHarmony command line;

[0010] Generating a test instruction according to the test item, the test instruction being used to instruct the target to-be-tested terminal to run an application matching the application information based on the test item;

[0011] Receiving a test result of the target to-be-tested terminal.

[0012] To solve the above technical problems, another technical solution adopted by the present application is:

[0013] A distributed payment system comprising at least two payment terminals and a test terminal;

[0014] The test terminal is used for testing the OpenHarmony application on the payment terminal, the test terminal is connected with all the payment terminals, and the test terminal is used for:

[0015] Obtaining application information of a to-be-tested application, the to-be-tested application being an OpenHarmony application;

[0016] Polling a target to-be-tested terminal, the target to-be-tested terminal including a payment terminal connected with the test terminal;

[0017] Obtaining a test item input by a user, the test item including a test script, the test script being generated by using a cross-platform script tool through an OpenHarmony command line;

[0018] Generating a test instruction according to the test item, the test instruction being used for instructing the target to-be-tested terminal to run an application matched with the application information based on the test item;

[0019] Receiving a test result of the target to-be-tested terminal.

[0020] In order to solve the above technical problems, another technical solution adopted by the present application is:

[0021] An electronic device includes a memory, a processor, and a computer program stored on the memory and running on the processor, and the processor implements the above-mentioned test method based on the OpenHarmony application when executing the computer program.

[0022] The beneficial effects of this invention are as follows: The test terminal of this application is used to test the OpenHarmony application on the terminal under test. The test terminal obtains the application information of the application under test, wherein the application under test is an OpenHarmony application; then it polls to obtain the target terminal under test connected to the test terminal; it obtains the test items input by the user, wherein the test items include test scripts, which are generated using a cross-platform scripting tool via the OpenHarmony command line; then, it generates test instructions based on the test items, which instruct the target terminal under test to run the application that matches the application information based on the test items; finally, it receives the test results from the target terminal under test, thus completing the test of the OpenHarmony application on the terminal under test. Using the method of this application, since the test scripts in the test items are generated using a cross-platform scripting tool via the OpenHarmony command line, the user can directly write and modify the test scripts on the test terminal, making the writing process convenient; moreover, the cross-platform scripting tool itself has high stability characteristics, which makes the test scripts more stable during testing. Therefore, the method of this application can improve the testing efficiency and effectiveness of OpenHarmony applications in the OpenHarmony system, effectively solving the problems of low testing efficiency and poor testing effectiveness in related technologies for testing OpenHarmony applications in the OpenHarmony system. Attached Figure Description

[0023] Figure 1 This is a flowchart illustrating the steps of a testing method based on an OpenHarmony application in an embodiment of the present invention.

[0024] Figure 2 This is a connection diagram of a testing method based on the OpenHarmony application in an embodiment of the present invention;

[0025] Figure 3 This is a schematic diagram illustrating a scripting method for a testing method based on an OpenHarmony application, as described in an embodiment of the present invention.

[0026] Figure 4 This is a schematic diagram of the architecture of a test system based on the OpenHarmony application in an embodiment of the present invention;

[0027] Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0028] In order to make the technical problems, technical solutions and beneficial effects to be solved in the present application clearer, the present application will be further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.

[0029] In the following description, specific details are set forth such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. However, it should be apparent to those skilled in the art that the present application can be practiced without such specific details. In other instances, well-known systems, devices, circuits, and methods have been described in detail to avoid unnecessary detail.

[0030] It should be understood that when used in the specification and the appended claims of the present application, the term "comprising" indicates the presence of the 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.

[0031] In the present application, the reference to "one embodiment" or "some embodiments" means that the specific features, structures or characteristics described in connection with the embodiment are included in one or more embodiments of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in other some embodiments" and the like appearing in different places in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "comprise", "include", "have" and their variants mean "including but not limited to", unless otherwise specifically emphasized.

[0032] In the related art, the scene-based testing method is a method of testing based on actual use scenarios. It simulates real use scenarios to comprehensively and deeply test software to ensure that the performance and functions of the software can operate normally under various conditions.

[0033] With the continuous development of financial digital service terminals and the increasing demand for localization, more and more financial terminals will choose to use a system based on the OpenHarmony platform. However, the current OpenHarmony application testing of the OpenHarmony system has the problems of low testing efficiency and poor testing effect.

[0034] However, the current known OpenHarmony native application testing scheme has the following problems:

[0035] (1) Writing test scripts is inconvenient and requires integration within the application project. For example, developers currently use the DevEco tool (HUAWEIDevEco Studio) to test native OpenHarmony applications. DevEco is a development tool built by Huawei based on the IntelliJ IDEA Community open-source version, providing a one-stop distributed application development platform for all scenarios and multiple devices, supporting distributed multi-terminal development and distributed multi-terminal debugging; it is a development tool with basic code development, compilation, building, and debugging functions. However, currently, when developers use this tool, they can only modify test scripts within the application project of this tool, and after modification, they need to click to execute, which is cumbersome. Therefore, when testing native OpenHarmony applications, developers must install the DevEco tool, modify the test scripts within the DevEco tool's application project, and then click to execute them separately, which is extremely inconvenient.

[0036] (2) Unable to run stably a specified number of times. DevEco tools often cannot run stably a specified number of times. If the number of runs is too many, DevEco tools will encounter problems such as running errors or failure to run.

[0037] (3) It does not support simultaneous testing on multiple devices. DevEco tools can generally only process a single device and cannot test multiple devices simultaneously. Therefore, in actual testing, testing multiple devices simultaneously requires running DevEco tools on multiple test terminals, which is cumbersome.

[0038] (4) Does not support all input events. Since DevEco tools can only handle user-written programs and cannot perform automated testing, the OpenHarmony stability testing tool wukong (hereinafter referred to as wukong tool) was developed as an important component of the OpenHarmony toolset. It implements basic application stability testing capabilities such as random event injection, control injection, exception handling, report generation, and data traversal screenshots of Abilities. Although wukong tool supports recording and replaying user operations, it does not support all input events. For example, it does not support swipe or key input events, and the interval between events cannot be specified. In other words, it only provides a fixed set of choices.

[0039] (5) Unable to record memory information simultaneously. The Wukong tool cannot record memory information simultaneously, and therefore cannot obtain some test data.

[0040] Therefore, the OpenHarmony native application test tool in the related art cannot meet the test requirements. The method corresponding to the present application can implement simultaneous testing of multiple devices, and meet the stress testing of the transaction scenario of the acquirer application.

[0041] The present application provides a test method, system and electronic device based on OpenHarmony application to solve the problems (1)-(5) in the related art.

[0042] The technical scheme of the test method of the present application will be introduced in detail below.

[0043] Please refer to Figure 1 The present application provides a test method based on OpenHarmony application, which is used for testing terminal, and the testing terminal is used for testing OpenHarmony application on the to-be-tested terminal; the testing terminal is connected with at least one to-be-tested terminal.

[0044] Please refer to Figure 2 The testing terminal can be a computer (PC), a mobile phone and other intelligent devices that can write code, and the to-be-tested terminal can be a cash register, a financial POS machine, a smart POS machine, a card swiping machine, a face recognition terminal, a palm print recognition terminal and a code scanner, etc. The to-be-tested terminal is an intelligent terminal installed with OpenHarmony application, wherein the to-be-tested terminal includes an intelligent device such as an OpenHarmony device (OH device), that is, the to-be-tested terminal can use OpenHarmony as an operating system to realize distributed connection with other terminals. When referring to distributed, the first corresponding is distributed computing. Distributed computing divides a computing problem into many small computing parts, and then distributes these parts to many networked computers participating in computing for parallel processing, and finally integrates these computing results to obtain the final result; distributed storage stores data on multiple independent machine devices. The biggest advantage of distributed computing is to utilize the computing power of distributed connected computers. The distributed connection of the present application is the same. The to-be-tested terminals of the present application can be distributed connected, so that the capabilities of other to-be-tested terminals can be utilized to process payment. The distributed connection of the present application can utilize the distributed soft bus to connect. The distributed soft bus is a software that is similar to a hardware physical bus, and all devices connected on the bus are in the form of software. It can be understood that software is a device by device, and since software can realize decentralization and distributed arrangement. Moreover, the most important feature is that the devices in the distributed soft bus can call the capabilities of other devices to process requests. For example, when a mobile phone and a computer are in distributed connection, the mobile phone can apply the high computing power of the computer to process pictures in the mobile phone, and the computer can use the high-definition camera of the mobile phone to take pictures, etc.

[0045] The application is based on an OpenHarmony application test method including steps S110-S150.

[0046] Step S110, application information of a to-be-tested application is acquired, the to-be-tested application being an OpenHarmony application.

[0047] The application information can include application ID, application package name, application name, application version number information and other application-related information, for subsequent matching; matching can be performed based on the application package name only. For example, if it is desired to test the test item of continuous clicking of a payment application in a smart POS machine and still being effective, the smart POS machine is used as a to-be-tested terminal, and the payment application is used as a to-be-tested application. The application information of the payment application can be acquired through step S110, for example, the application ID thereof is PAYV1.0.

[0048] Step S120, a target to-be-tested terminal is acquired by polling, the target to-be-tested terminal including a to-be-tested terminal connected to a test terminal.

[0049] The test terminal and the to-be-tested terminal can be connected through a wired or wireless manner, for example, the to-be-tested terminal is connected to the test terminal through a USB or TCP. The test is performed through TCP, which meets the scenario of a small number of USB interfaces on a PC. Each to-be-tested terminal of the application has a unique device identifier. If the to-be-tested terminal is connected to the device through a wireless network, the identifier can be in the IP address:port format. If the to-be-tested terminal is connected through a USB, the device identifier is a device serial number (SN). As shown in the following table, the test terminal (PC) can poll all connected to-be-tested terminals (OH devices), and select one or more to-be-tested terminals connected to the test terminal as target to-be-tested terminals for testing according to actual test requirements. Figure 2

[0050] For example, when it is desired to test the test item of continuous clicking of a payment application in a smart POS machine and still being effective, the smart POS machine is connected to the test terminal through a wired or wireless manner, and then step S120 is performed. At this time, the smart POS machine can be used as the acquired target to-be-tested terminal.

[0051] Step S130, a test item input by a user is acquired, the test item including a test script, and the test script is generated by using a cross-platform script tool through an OpenHarmony command line.

[0052] ​After the test terminal PC runs the script, the user is prompted to input the application package name that needs to be run; the application package name is similar to the ID of the application to be tested. After the application package name is input, the application information to be tested this time is obtained, and then the OH device is connected for testing. The test script can be obtained based on the PC end. The cross-platform script tool includes PowerShell (a cross-platform task automation solution composed of a command-line shell, a scripting language, and a configuration management framework. PowerShell can run on Windows / Linux / macOS systems). The OpenHarmony command refers to the command-line tool provided for developers for debugging, which can be an HDC uinput command tool (hereinafter referred to as HDC uinput command) or other command-line tools designed for OpenHarmony. Through the tool, the development machine or the simulator can be interacted with on Windows / Linux / MacOS systems. Step S130 can be executed before step S120, that is, after the test terminal obtains the test item input by the user, the target terminal to be tested is polled. For example, taking the test item of continuous clicking of the payment application in the intelligent POS machine and still being effective as an example, the corresponding test script can be the process of continuous clicking of the payment application input by the user. The user can write the required test script according to the needs through the cross-platform script tool on the PC corresponding to the test terminal.

[0053] In an embodiment of the present application, the cross-platform script tool includes:

[0054] CukeTest: CukeTest is a cross-platform automated testing tool that supports Qt automation. Whether the application is built based on Qt Widgets or Qt Quick, CukeTest can achieve its automation.

[0055] PowerShell: PowerShell is a cross-platform task automation solution composed of a command-line shell, a scripting language, and a configuration management framework. PowerShell can run on Windows, Linux, and macOS.

[0056] Robot Framework: Robot Framework is a general automated testing framework that supports cross-platform task automation.

[0057] For example, the user can write a test script through the PowerShell tool on the PC corresponding to the test terminal through the OpenHarmony command line, such as the HDC uinput command.

[0058] Step S140, according to the test item, a test instruction is generated, the test instruction is used to instruct the target to be tested terminal to run the application matched with the application information based on the test item.

[0059] That is, the OH device as the target to be tested terminal runs the application matched with the above-mentioned application ID, application name and other application information based on the test script to perform the test. For example, taking the test item of continuously clicking the payment application in the intelligent POS machine and still being effective as an example, the intelligent POS machine as the to-be-tested terminal, the test instruction is used to instruct the intelligent POS machine to run the payment application with the ID of PAYV1.0 based on the process of user inputting continuous clicks of the payment application.

[0060] Step S150, receiving the test result of the target to be tested terminal. That is, receiving the test result fed back by all OH devices in the test.

[0061] The test terminal of the present application is used to test the OpenHarmony application on the to-be-tested terminal. The test terminal obtains the application information of the to-be-tested application, wherein the to-be-tested application is an OpenHarmony application. Then, the target to be tested terminal connected with the test terminal is obtained by polling. The test item input by the user is obtained, wherein the test item includes a test script, and the test script is generated by using a cross-platform script tool through an OpenHarmony command line. Then, according to the test item, a test instruction is generated, the test instruction is used to instruct the target to be tested terminal to run the application matched with the application information based on the test item. Finally, the test result of the target to be tested terminal is received, and the test of the OpenHarmony application on the to-be-tested terminal is completed. By using the method of the present application, since the test script in the test item is generated by using a cross-platform script tool through an OpenHarmony command line, the user can directly write and modify the test script on the test terminal, and the writing process is convenient. Moreover, the cross-platform script tool itself has high stability characteristics, which can make the test script more stable during testing. Therefore, by using the method of the present application, the test efficiency and test effect of the OpenHarmony application of the OpenHarmony system can be improved, and the problem of low test efficiency and poor test effect of the OpenHarmony application of the OpenHarmony system in the related art is effectively solved.

[0062] Specifically, the method of the present application generates the test script by using a cross-platform script tool through an OpenHarmony command line. By using the scheme of the present application, the following technical effects can be achieved:

[0063] Firstly, the present application generates a test script through an OpenHarmony command line by using a cross-platform scripting tool, for example, a test script is written by using a PowerShell scripting tool through an HDC uinput command on a test terminal to simulate user input without being integrated in an application project, thereby avoiding the limitation of the OpenHarmony automatic test framework scheme that needs to be written in DevEco, that is, solving the problem of inconvenient test script writing and the need to be integrated in the application project.

[0064] Secondly, the cross-platform scripting tool (for example, the PowerShell scripting tool) can ensure high stability, so that the test stability can be maintained when performing multiple repetitive tests, meeting the current test frequency requirement, that is, solving the problem that DevEco cannot stably run a specified number of tests.

[0065] Thirdly, the HDC uinput command supports specifying the target device of the command through a parameter, and the PowerShell tool can operate multiple devices simultaneously, so all target devices of the command can be specified through the HDC uinput command, and then the PowerShell tool is used to operate simultaneously, thereby solving the problem that DevEco does not support multiple devices for testing at the same time.

[0066] Fourthly, the HDC uinput command can realize full event input, thereby solving the problem that the Wukong tool does not support all input events.

[0067] Fifthly, the HDC uinput command can write code through related instructions, return memory information through the PowerShell tool, and then record the memory information to a file through the PowerShell tool to realize memory information recording during the running process, thereby solving the problem that the wukong tool cannot record memory information simultaneously. Thus, the pressure test of the transaction scenario of the acquirer application is met, and the problems of low test efficiency and poor test effect are solved.

[0068] Meanwhile, the scheme of the present application is particularly suitable for acquirer applications in the financial field. Since the acquirer application in the financial field needs higher stability, scene pressure testing needs to be performed. The so-called scene pressure testing refers to continuously and frequently testing some typical use scenes of a device to collect fault problems and related positioning information of the device during the period to assist device developers to evaluate and optimize the stability of the design in the scene.

[0069] The scheme of the present application can well complete the above test, and in addition, the scheme of the present application can also be used in tests including hibernation wake-up, power on / off, etc. For each problem exposed in the test, the test terminal collects fault-related information from multiple sources, including but not limited to abnormal stack, crash stack, Hilog context, etc., to assist the developer to quickly locate the problem of the acquirer application. Among them, for the transaction process commonly used in financial applications, it is required to keep the memory and CPU usage stable to ensure that long-time continuous transactions can be performed and need to be tested. That is, the method of the present application can be used in continuous high-frequency hibernation wake-up, power on / off, application clicking, etc. Test scenarios.

[0070] In an embodiment of the present application, the method of step S130, acquiring the test item input by the user, includes: acquiring the test script and the running times input by the user; the running times are used to indicate the number of times that the target terminal under test runs the test script. By acquiring the test script and the running times input by the user, the test script can be executed for a corresponding number of times according to the actual test requirements of the user to meet the test requirements. For example, the user inputs the test script corresponding to the test item of continuously clicking the payment application and still being valid, and the running times are 100 times; which indicates that the test item needs to be executed for 100 times.

[0071] In an embodiment of the present application, the method of step S120, polling the target terminal under test, includes steps S210-S220.

[0072] Step S210, save the device information of the target terminal under test.

[0073] For example, polling all the device information of the currently connected devices, such as obtaining the device information of OH device 1, OH device 2 and OH device N; wherein polling is to determine how many OH devices are connected to the PC, for example, there are 3 OH devices, then save the information of the 3 OH devices; for example, OH device 1 connects to the PC through USB or TCP, and the PC detects and reads the device information, if the information of OH device 1 is not saved, then save it. For each OH device, the test terminal will save the corresponding device information and connection information; such as saving the device information of the OH device by saving the IP address corresponding to the OH device, or saving the device SN number, code / ID of the OH device, etc. For each newly saved OH device, the PC reads all the single test scripts written in step 130, and prompts the user to input the test item and the number of times that need to be run; that is, prompting the user to input the script and the number of times that need to be tested on the PC to adapt to different functions; and then running the test item.

[0074] Step S220, when the target terminal to be tested is disconnected from the test terminal, stop testing the disconnection test terminal, and delete the device information of the disconnection test terminal. The disconnection test terminal includes the target terminal to be tested disconnected from the test terminal.

[0075] Please refer to Figure 2 If the OH device 1 is disconnected from the PC terminal during the execution of step S210, the PC terminal deletes the device information related to the OH device 1, and stops testing the OH device 1. By deleting the information, the OH device 1 can avoid skipping step S210 when reconnected. At the same time, the test results completed by the OH device 1 during the test process will be saved, and only the device information of the OH device 1 will be deleted.

[0076] In an embodiment of the present application, step S150, the method for receiving the test result of the target terminal to be tested, comprises steps S310-S320.

[0077] Step S310, obtain the preset interval number. For example, use time as the interval number, or use test number as the interval number. Different parameters can be selected as the interval number according to the test requirements.

[0078] Step S320, if the current test number reaches the interval number, the application information of the application to be tested is echoed and recorded, and the test is completed.

[0079] The current test number includes the number of times that the target terminal to be tested runs the application matched with the application information based on the test item. For example, if time is used as the interval number, the application information of the target test application, such as memory and CPU information, is echoed and recorded in the PC file every time the corresponding time interval is reached. If test number is used as the interval number, the application information of the application to be tested is echoed and recorded every time the corresponding test interval is reached. The memory information is mainly returned by the hdc hichumper related instruction, and then recorded to the file by PowerShell to realize the memory information recording of the running process. At the same time, hdc can realize full event input, and combined with the sleep command control event interval realized by PowerShell script.

[0080] In an embodiment of the present application, before the step S110 of acquiring the application information of the to-be-tested application, the method further comprises: a step S410 of acquiring at least one test script input by the user through the cross-platform script tool. That is, the test script can be one or more. Different test scripts represent different test schemes, and different test schemes can respectively test different functions of the to-be-tested application. Therefore, the user can select a specific test script for testing according to the test purpose. For example, the user needs to test not only the test item of the continuous clicking of the payment application in the intelligent POS machine and still being effective, but also the test item of the start-up time of the payment application. Therefore, the user can complete the writing of the corresponding test script on the PC based on CukeTest, PowerShell or Robot Framework.

[0081] In an embodiment of the present application, the step S410 of acquiring the at least one test script input by the user through the cross-platform script tool comprises a step S420.

[0082] The step S420 comprises: S4201, acquiring the at least one test script input by the user through the cross-platform script tool calling the command line tool and / or the custom tool; wherein the command line tool is used to generate the test script by writing commands; and the custom tool is used to automatically generate the test script by recording the user operation. Figure 3 Taking the OH device 1 as an example, the following is described:

[0083] When the single-item test script is written on the PC, the HDCuinput related instructions are used to write the simulated user input (the test script is written by writing commands) or the wukong (wukong is an OpenHarmony stability test automation tool, which supports recording user operations and playback, and is pre-installed in the system after the 3.2 system version) is used to record the simulated user operation (the test script is automatically generated by recording the user operation).

[0084] For example, a script of clicking a specified point on the screen and pressing the back key after one second is written, and the script is specifically as follows:

[0085] hdc shell uinput-T-c 400 530 / represents clicking the screen coordinates (400, 530);

[0086] Start-Sleep-Seconds 1 / represents waiting for 1 second;

[0087] hdc shell uinput-K-d 2-u 2 / represents pressing the back key;

[0088] Or through the playback of the operation of the pre-recording of the hdc call wukong to generate the above script, that is, to generate the above script by recording the operation of clicking the screen specified point interval one second and then pressing the back. Through the hdc, the full event input is realized, that is, most of the user inputs are simulated, including clicking, sliding, and key input, etc. Combined with the PowerShell script sleep command to realize the control of the event interval. At the same time, based on the custom script, the custom script can be written for the actual application scene, and multiple instruction input schemes are supported to meet the user's test requirements.

[0089] In an embodiment of the present application, the test terminal is connected with the first to-be-tested terminal for a first connection, and the test terminal is connected with the second to-be-tested terminal for a second connection. The first connection and the second connection include Bluetooth, WIFI, 4G or USB. According to the test item, a test instruction is generated, including step S510.

[0090] S510, according to the test item, a first test instruction and a second test instruction are generated, and the first test instruction is sent to the first to-be-tested terminal through the first connection, and the second test instruction is sent to the second to-be-tested terminal through the second connection. The first test instruction is used to instruct the first to-be-tested terminal to run an application matched with the application information based on the test item; the second test instruction is used to instruct the second to-be-tested terminal to run an application matched with the application information based on the test item. For example, the test terminal PC is connected with the OH device 1 through the USB connection, and the test terminal PC is connected with the OH device 2 through the TCP connection. Then, the test terminal PC generates the first test instruction and the second test instruction according to the test item, sends the first test instruction to the OH device 1 through the USB connection, sends the second test instruction to the OH device 2 through the TCP connection, and instructs the OH device 1 and the OH device 2 to test.

[0091] In an embodiment of the present application, the test terminal is connected with the first to-be-tested terminal for a first connection, and the first to-be-tested terminal is connected with the second to-be-tested terminal for a distributed connection. The first connection includes Bluetooth, WIFI, 4G or USB. The test terminal is not connected with the second to-be-tested terminal. According to the test item, a test instruction is generated, including steps S610-S620.

[0092] S610, according to the test item, a first test instruction is generated, and the first test instruction is sent to the first to-be-tested terminal through the first connection; the first test instruction is used to instruct the first to-be-tested terminal to run an application matched with the application information based on the test item. For example, the test terminal PC is connected with the OH device 1 through the USB connection, and the OH device 1 is connected with the OH device 2 in a distributed manner. Then, the test terminal PC generates the first test instruction according to the test item, and sends the first test instruction to the OH device 1 through the USB connection.

[0093] S620, generate the second test instruction and the forwarding instruction according to the test item, and send the second test instruction and the forwarding instruction to the first terminal under test through the first connection, wherein the forwarding instruction is used to instruct the first terminal under test to forward the second test instruction to the second terminal under test through the distributed connection; and the second test instruction is used to instruct the second terminal under test to run the application matched with the application information based on the test item. Since in a specific application scenario, the test terminal may not be directly connected with the terminal under test, it is necessary to generate the forwarding instruction, and the terminal under test connected with the test terminal obtains the forwarding instruction and then sends it to the corresponding terminal under test. For example, the test terminal PC sends the second test instruction and the forwarding instruction to the OH device 1 through the USB connection; the OH device 1 forwards the second test instruction to the OH device 2 through the distributed connection under the instruction of the forwarding instruction; and then the OH device 2 performs the test based on the second test instruction. The scheme of the application can find the terminal under test corresponding to the forwarding instruction from all terminals under test connected in a distributed manner to perform the test when the terminal under test connected in a distributed manner receives the forwarding instruction, that is, the terminal under test can effectively use the computing resources of any terminal under test connected in a distributed manner, and improve the diversity and applicability of the payment method.

[0094] Moreover, the scheme of the application can expand the application scenario and realize the test of the OpenHarmony application of other terminals under test not connected with the test terminal. For example, when the test terminal is connected with the first terminal under test, the test terminal can realize the test of the OpenHarmony application of all terminals under test connected with the first terminal under test in a distributed manner, and improve the applicability.

[0095] In an embodiment of the application, the OpenHarmony application test method can be applied to a test machine, and the test machine and the plurality of OH devices are connected through USB wired connection or TCP wireless connection; wherein the OH devices include POS machines, cash registers and other devices, and the OH devices are installed with corresponding test applications. The method includes steps S710-S760.

[0096] S710, obtain at least one test script of a user; wherein the user can use HDCuinput related instructions to write simulated user input or wukong to record simulated user operation; and the test script is written by using a powershell tool.

[0097] S720, obtain an application ID to be tested.

[0098] S730, poll all connected device information; when one of the OH devices is connected with the PC through USB or TCP, the PC detects and reads the device information and saves it.

[0099] S740, obtaining a script category and a running number input by a user.

[0100] S750, running a script corresponding to the script category and the running number, wherein when the script is running, the OH device is instructed to execute the application to be tested, and the memory and CPU information of the target application to be tested are echoed and recorded in a PC file at a certain number of times, and the test is completed.

[0101] S760, if the OH device is disconnected from the PC in step S730, the PC stops the test item of the corresponding device and deletes the information of the corresponding device.

[0102] Please refer to Figure 4 Another embodiment of the present application provides a distributed payment system, Figure 4 An architecture schematic diagram of a distributed payment system 100 provided by an embodiment of the present application is shown, which includes at least two payment terminals 102 and a test terminal 101, the test terminal 101 is used to test the OpenHarmony application on the payment terminal, in some embodiments, the test terminal is connected with all the payment terminals 102, and the test terminal 101 is used to:

[0103] Obtain application information of an application to be tested, the application to be tested being an OpenHarmony application;

[0104] Polling obtains a target terminal to be tested, the target terminal to be tested including a payment terminal 102 connected with the test terminal 101;

[0105] Obtain a test item input by a user, the test item including a test script, the test script being generated by using a cross-platform script tool through an OpenHarmony command line;

[0106] Generate a test instruction according to the test item, the test instruction being used to instruct the target terminal to be tested to run an application matched with the application information based on the test item;

[0107] Receive a test result of the target terminal to be tested.

[0108] In some other embodiments, the test terminal is connected with at least one payment terminal, and the payment terminals are distributedly connected. The payment terminal 102 can be the above-mentioned terminal to be tested, and the corresponding content of the test terminal 101 and the terminal to be tested in the distributed payment system has been disclosed in the above part, and will not be described here.

[0109] The application has the beneficial effects that: the generation of the test script is performed through the OpenHarmony command line by using the cross-platform script tool, the user input can be simulated based on the hdc command tool, thereby avoiding the limitation that the OpenHarmony automatic test framework scheme needs to be programmed in DevEco. The PowerShell script can ensure high stability and meet the current test frequency requirement. Meanwhile, the hdc command tool supports specifying the target device of the command through the parameter, and the PowerShell can be combined to realize the operation of multiple devices by the PC at the same time; and the hdc command tool can realize the full event input and the memory information return, and the memory information is recorded to the file by the PowerShell to realize the memory information recording in the running process. Therefore, the stress test of the transaction scene of the acquirer application is met, and the problems of low test efficiency and poor test effect are solved.

[0110] Please refer to Figure 5 A further embodiment provides an electronic device 300, comprising a memory 301, a processor 302, and a computer program stored in the memory 301 and running on the processor 302, wherein the processor 302 implements each step of the above-mentioned test method based on OpenHarmony application when executing the computer program.

[0111] The test method based on OpenHarmony application has been disclosed in the above part, and will not be repeated here.

[0112] In summary, the test method, system and electronic device based on OpenHarmony application provided by the application generate the test script through the OpenHarmony command line by using the cross-platform script tool, the user input can be simulated based on the hdc command tool, thereby avoiding the limitation that the OpenHarmony automatic test framework scheme needs to be programmed in DevEco. The PowerShell script can ensure high stability and meet the current test frequency requirement. Meanwhile, the hdc command tool supports specifying the target device of the command through the parameter, and the PowerShell can be combined to realize the operation of multiple devices by the PC at the same time; and the hdc command tool can realize the full event input and the memory information return, and the memory information is recorded to the file by the PowerShell to realize the memory information recording in the running process. That is, the problems (1)-(5) existing in the prior art are solved, thereby meeting the stress test of the transaction scene of the acquirer application, and solving the problems of low test efficiency and poor test effect.

[0113] The above merely illustrates the embodiments of the present application, and is not intended to limit the patent scope of the present application. Any equivalent transformation or direct or indirect application in the related technical field based on the content of the present application specification and drawings is also included in the patent protection scope of the present application.

Claims

1. A test method based on OpenHarmony applications, characterized in that, A test terminal is used for testing an OpenHarmony application on a terminal to be tested, the test terminal is connected with at least one terminal to be tested, and the method comprises the following steps: Obtaining application information of an application to be tested, the application to be tested being an OpenHarmony application; Polling a target terminal to be tested, the target terminal to be tested including the terminal to be tested connected with the test terminal; Obtaining a test item input by a user, the test item including a test script, the test script being generated by an OpenHarmony command line through a cross-platform script tool; Generating a test instruction according to the test item, the test instruction being used for instructing the target terminal to be tested to run an application matched with the application information based on the test item; Receiving a test result of the target terminal to be tested; The test terminal is connected with a first terminal to be tested, the first terminal to be tested is connected with a second terminal to be tested in a distributed manner, the first connection includes Bluetooth, WiFi, 4G or USB, and the test terminal is not connected with the second terminal to be tested; the test instruction is generated according to the test item, and the first test instruction is sent to the first terminal to be tested through the first connection; The second test instruction and a forwarding instruction are generated according to the test item, and the second test instruction and the forwarding instruction are sent to the first terminal to be tested through the first connection, wherein the forwarding instruction is used for instructing the first terminal to be tested to forward the second test instruction to the second terminal to be tested through the distributed connection; The first test instruction is used for instructing the first terminal to be tested to run an application matched with the application information based on the test item; The second test instruction is used for instructing the second terminal to be tested to run an application matched with the application information based on the test item. The test item input by the user is obtained, and the test item includes:

2. The test method based on OpenHarmony application according to claim 1, characterized in that, The test script input by the user and the number of running times are obtained; the number of running times is used for instructing the target terminal to be tested to run the test script a number of times. After the target terminal to be tested is polled, the method further comprises the following steps:

3. The test method based on OpenHarmony application according to claim 1, characterized in that, Saving device information of the target terminal to be tested; When the target terminal to be tested is disconnected with the test terminal, the test on the disconnection test terminal is stopped, and the device information of the disconnection test terminal is deleted; The disconnection test terminal includes the target terminal to be tested disconnected with the test terminal. The test result of the target terminal to be tested is received, and the test result includes the following steps:

4. The test method based on OpenHarmony application according to claim 2, characterized in that, Obtaining a preset interval number; If the current test number reaches the interval number, the application information of the application to be tested is echoed and recorded, and the test is completed; The current test number includes the number of times that the target terminal to be tested runs the application matched with the application information based on the test item in the current stage. Before the application information of the application to be tested is obtained, the method further comprises the following steps:

5. The test method based on OpenHarmony application according to claim 1, characterized in that, Obtaining at least one test script input by a user through a cross-platform script tool. The at least one test script input by the user through the cross-platform script tool includes the following steps:

6. The test method based on OpenHarmony application according to claim 5, characterized in that, ​ Acquire at least one test script input by a user through a cross-platform script tool calling a command line tool and / or a custom tool; The command line tool is configured to generate the test script by writing commands; The custom tool is configured to automatically generate the test script by recording user operations.

7. The test method based on OpenHarmony application according to claim 1, characterized in that, The test terminal is connected to a first terminal to be tested and a second terminal to be tested, the first connection and the second connection include Bluetooth, WiFi, 4G or USB, and the test instruction is generated according to the test item, including: The first test instruction is used to instruct the first terminal to be tested to run an application matching the application information based on the test item. The second test instruction is used to instruct the second terminal to be tested to run an application matching the application information based on the test item. At least two payment terminals and a test terminal are included; 8. A distributed payment system, characterized by The test terminal is configured to test an OpenHarmony application on the payment terminal, the test terminal is connected to at least one payment terminal, and the test terminal is configured to: Acquire application information of an application to be tested, the application to be tested being an OpenHarmony application; Polling is performed to acquire a target terminal to be tested, the target terminal to be tested including the payment terminal connected to the test terminal; Acquire a test item input by a user, the test item including a test script, and the test script being generated by using a cross-platform script tool through an OpenHarmony command line; The test instruction is used to instruct the target terminal to be tested to run an application matching the application information based on the test item. Receive a test result of the target terminal to be tested. The test terminal is connected to a first payment terminal, the first payment terminal is connected to a second payment terminal in a distributed manner, the first connection includes Bluetooth, WiFi, 4G or USB, and the test terminal is not connected to the second payment terminal, and the test instruction is generated according to the test item, including: The first test instruction is generated according to the test item, and the first test instruction is sent to the first payment terminal through the first connection. The second test instruction and a forwarding instruction are generated according to the test item, and the second test instruction and the forwarding instruction are sent to the first payment terminal through the first connection, and the forwarding instruction is used to instruct the first payment terminal to forward the second test instruction to the second payment terminal through the distributed connection. The first test instruction is used to instruct the first payment terminal to run an application matching the application information based on the test item. The second test instruction is used to instruct the second payment terminal to run an application matching the application information based on the test item. ​ 9. An electronic device comprising a memory, a processor, and a computer program stored on the memory and running on the processor, characterized in that, The processor implements the computer program to implement the test method based on the OpenHarmony application in any one of claims 1-7.

Citation Information

Patent Citations

  • Test method and apparatus

    CN108459953A

  • Automatic testing method and device

    CN112306851A