Automatic testing method and system based on Lua script and medium

Through the automated testing method based on Lua scripts, the existing automation testing tools are solved in terms of flexibility and efficiency, and the test is automatically triggered after the device restart, the device startup parameters and page rendering time are obtained, and the test results are generated, which improves the testing efficiency and flexibility, reduces costs, and improves the system's adaptability and scalability.

CN119690819APending Publication Date: 2025-03-25FUJIAN STAR NET EVIDEO INFORMATION SYST CO LTD
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411515391.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-29
Publication Date
2025-03-25

AI Technical Summary

Technical Problem

Existing automated testing tools have shortcomings in flexibility and efficiency, which are difficult to meet the testing needs of complex applications, and require additional equipment and a stable network environment, affecting testing efficiency and stability.

Method used

Using an automated test method based on Lua scripts, the internal functions of the application to be tested are obtained through JAVA reflection characteristics, and the Lua test script is built, which automatically triggers the test after the device is restarted, obtains the device startup parameters and page rendering time, and generates test results.

Benefits of technology

It improves testing efficiency and flexibility, reduces labor and material costs, realizes decoupling from business processes, improves the adaptability and scalability of the system, and does not rely on long connections, improving test stability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119690819A_ABST
    Figure CN119690819A_ABST
Patent Text Reader

Abstract

The invention provides an automatic testing method and system based on a Lua script and a medium. The method comprises the steps that an internal function of a to-be-tested application is obtained according to JAVA reflection characteristics, a calling function of each page of the to-be-tested application is configured, and the Lua testing script is constructed; issuing the Lua test script to at least one to-be-tested device installed with the to-be-tested application through a network; starting a test, executing equipment restarting operation, and obtaining related parameters of equipment starting through a Lua script; opening corresponding pages of the to-be-tested application through the page calling function, and calculating rendering time of each page; and generating and outputting a test result according to the obtained equipment startup related parameters and the rendering time of each page. According to the invention, the labor cost can be reduced, the test efficiency is improved, and the test flexibility and expandability are enhanced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of application software testing, and in particular to an automatic testing method, system and medium based on Lua script. Background Art

[0002] In the process of software development and testing, performance testing is an important part of ensuring application stability and user experience. Traditional performance testing methods usually rely on manual testing and manual recording of performance parameters. These methods are not only time-consuming and labor-intensive, but also easily affected by human factors, resulting in reduced accuracy and consistency of test results.

[0003] Although the existing automated testing tools (python scripts) can improve efficiency, they need to simulate page click operations in advance, which requires considering the layout and coordinate distribution of the device application UI interface. When facing irregular page elements, the accuracy of positioning and operation is often insufficient. When the business process changes and the UI interface needs to be modified, the corresponding test script also needs to be readjusted to obtain the new page layout and required coordinates. This testing method that is closely coupled with the business process has caused great flexibility and adaptability problems. The existing testing tools cannot meet the testing needs of complex applications. In addition, the existing page performance testing generally requires the cooperation of additional equipment, and the testing process is realized by maintaining a long connection interaction between the additional equipment and the device under test. This not only requires an increase in testing costs, but also requires a stable network environment, which affects the stability of the test and the test efficiency. Summary of the invention

[0004] The technical problem to be solved by the present invention is to provide an automated testing method, system and medium based on Lua scripts to overcome the problems of poor flexibility and low efficiency of existing automated testing.

[0005] In a first aspect, the present invention provides an automated testing method based on Lua scripts, the method comprising:

[0006] Step S1, obtaining the internal functions of the application to be tested according to the JAVA reflection characteristics, configuring the calling functions of each page of the application to be tested through the Lua language, and constructing a Lua test script;

[0007] Step S2: Send the Lua test script to one or more devices to be tested installed with the application to be tested via the network;

[0008] Step S3: Start the test, execute the device restart operation, and obtain the relevant parameters of the device startup through the Lua script;

[0009] Step S4: Open the corresponding page of the application to be tested through the page call function, and calculate the rendering time of each page;

[0010] Step S5: Generate and output test results based on the acquired device startup related parameters and rendering time of each page.

[0011] Furthermore, in step S3, the test is started by turning on a preset test mode flag on the device to be tested.

[0012] Furthermore, the test mode identifier is hidden in the application software to be tested, so that the tester can switch it.

[0013] Furthermore, in step S4, the rendering time of each page is calculated by: jumping the current page to the page corresponding to the calling function through the page calling function, and then grabbing the preset embedding data through the Lua script.

[0014] Furthermore, the buried data includes: a first time point when the page calling function is triggered, and a second time point when the page rendering corresponding to the calling function is completed, and the page rendering time is calculated by the first time point and the second time point.

[0015] Furthermore, after the Lua test script is sent to the device to be tested, it is stored in a storage path under the device memory card according to a predefined storage path, so that the test script can be obtained according to the path during subsequent test calls.

[0016] Furthermore, the device startup related parameters include at least one of the following: the time from when the device is powered on to when the application to be tested runs normally, and the memory idle rate and CPU idle rate after the device is started.

[0017] In a second aspect, the present invention provides an automated testing system based on Lua scripts, comprising:

[0018] The script construction module is used to obtain the internal functions of the application to be tested based on the JAVA reflection characteristics, configure the calling functions of each page of the application to be tested through the Lua language, and build a Lua test script;

[0019] The script delivery module is used to deliver the Lua test script to one or more devices under test installed with the application to be tested through the network;

[0020] The test startup module is used to start the test, perform device restart operations, and obtain relevant parameters for device startup through Lua scripts;

[0021] The application testing module is used to open the corresponding page of the application to be tested through the page call function and calculate the rendering time of each page;

[0022] The result output module is used to generate and output the test results according to the acquired device startup related parameters and the rendering time of each page.

[0023] Furthermore, in the test start module, the test is started by turning on a preset test mode flag on the device to be tested.

[0024] Furthermore, the test mode identifier is hidden in the application software to be tested, so that the tester can switch it.

[0025] Furthermore, in the application test module, the rendering time of each page is calculated by: jumping the current page to the page corresponding to the calling function through the page calling function, and then grabbing the preset embedding data through the Lua script.

[0026] Furthermore, the buried data includes: a first time point when the page calling function is triggered, and a second time point when the page rendering corresponding to the calling function is completed, and the page rendering time is calculated by the first time point and the second time point.

[0027] Furthermore, after the Lua test script is sent to the device to be tested, it is stored in a storage path under the device memory card according to a predefined storage path, so that the test script can be obtained according to the path during subsequent test calls.

[0028] Furthermore, the device startup related parameters include at least one of the following: the time from when the device is powered on to when the application to be tested runs normally, and the memory idle rate and CPU idle rate after the device is started.

[0029] In a third aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.

[0030] One or more technical solutions provided by the present invention have at least the following technical effects or advantages:

[0031] 1. Improve test efficiency:

[0032] The automated testing process significantly improves testing efficiency and reduces manual intervention.

[0033] 2. Reduce labor costs:

[0034] Through automation, the input of manpower and material resources is reduced and resource allocation is optimized.

[0035] 3. Enhanced flexibility:

[0036] Switch control and automatic triggering mechanisms make the testing process more flexible, enabling quick response to changes in business requirements and avoiding triggering script execution during non-testing phases.

[0037] 4. Provide accurate data:

[0038] Repeated testing and accurate performance parameter recording, and the generated test result reports provide strong support for subsequent performance analysis and optimization.

[0039] 5. Decoupling from business:

[0040] The present invention realizes decoupling from business processes and improves the adaptability and scalability of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The present invention will be further described below in conjunction with embodiments with reference to the accompanying drawings.

[0042] Figure 1 The present invention is a flowchart of an automated testing method based on Lua scripts in the first embodiment of the present invention.

[0043] Figure 2 This is a structural block diagram of an automatic testing system based on Lua scripts in Embodiment 2 of the present invention.

[0044] Figure 3 Schematic diagram of the structure of the medium in the third embodiment of the present invention. DETAILED DESCRIPTION

[0045] The embodiments of the present application provide a Lua script-based automated testing method, system and medium to solve the problems of low page positioning accuracy, high coupling between test scripts and application systems, poor flexibility, low testing efficiency, etc. in automated performance testing of existing software systems.

[0046] The technical solution in the embodiment of the present application has the following general idea: the present invention proposes a script automation test solution for integrated software, which controls performance testing through switches and flexibly pushes test scripts to the device for execution. After the device restarts, the script is automatically triggered, and the command line is used to query basic performance parameters such as the idle rate of the CPU and memory, and the UI jump function is called to simulate entering different function pages and record the page rendering time. This method effectively solves the problems of difficulty in locating interface elements and manual errors, and finally generates a test result report, which significantly reduces the non-value-added investment in manpower and material resources, and has high flexibility and strong scalability.

[0047] In order to better understand the above technical solution, the above technical solution will be described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0048] Embodiment 1

[0049] This embodiment provides an automated testing method based on Lua scripts. Figure 1 As shown, the following steps are included:

[0050] Step S1, obtaining the internal functions of the application to be tested according to the JAVA reflection characteristics, configuring the calling functions of each page of the application to be tested through the Lua language, and constructing a Lua test script;

[0051] Step S2: Send the Lua test script to one or more devices to be tested that have the application to be tested installed via the network; the test script can be sent to multiple devices at the same time to achieve synchronous testing of multiple devices;

[0052] Step S3, start the test, execute the device restart operation, and obtain the relevant parameters of the device startup through the Lua script. Specifically, turn on the pre-set test mode flag on the device to be tested, start the test, execute the device restart operation, and call the underlying Linux command through the Lua script to query the relevant parameters of the device startup;

[0053] Step S4: Open the corresponding page of the application to be tested through the page call function, and calculate the rendering time of each page;

[0054] Step S5: Generate and output test results based on the acquired device startup related parameters and rendering time of each page.

[0055] Preferably, in step S3, the test is started by turning on a pre-set test mode identifier on the device to be tested, and the test mode identifier is hidden in the application software to be tested for the tester to switch on and off.

[0056] Preferably, in step S4, the rendering time of each page is calculated by: jumping the current page to the page corresponding to the calling function through the page calling function, and then grabbing the preset embedding data through the Lua script.

[0057] The buried point data includes: the first time point of triggering the page call function, and the second time point of the page rendering corresponding to the call function, and the page rendering time is calculated by the first time point and the second time point. The present invention does not use the conventional positioning element method for testing. The method realizes the mutual call with the code function of the device application through the Lua script, and completes the flexible jump and detection of the corresponding page through the page call function; such as: when the application software to be tested is a song ordering system, the song ordering system includes multiple pages such as singers and songs. After the jump is completed, the logcat buried point log is captured by the Lua script to calculate the display time of each page, repeat 10 times, and take the average value to obtain a more accurate performance time. In this way, there is no need to consider the layout and coordinate distribution of the device application UI interface. Due to the embeddability and lightweight characteristics of Lua, it is more convenient to obtain device applications and related parameters, and the running loss of the device is small. At the same time, because there is no coupling between the script and the device application code, the Lua script can be modified and adjusted at any time according to different needs or test results and retested.

[0058] Preferably, after the Lua test script is sent to the device to be tested, it is stored in a storage path under the device memory card according to a predefined storage path.

[0059] Preferably, the device startup related parameters include at least one of the following: the time from when the device is powered on to when the application to be tested runs normally (the time for the system's underlying boot to run normally can be obtained through tracking points), the memory idle rate and CPU idle rate after the device is started. The CPU idle rate is obtained by reading the CPU idle rate 10 times after the device is started and calculating its average value, which can obtain more accurate device-related startup parameters.

[0060] Preferably, the test result is stored with a file name of result.txt and displayed in a format of test items and result values, such as startup time: 45 seconds.

[0061] Based on the same inventive concept, the present application also provides a system corresponding to the method in Example 1, see Example 2 for details.

[0062] Embodiment 2

[0063] In this embodiment, a Lua script-based automated testing system is provided. Figure 2 As shown, the system includes:

[0064] The script construction module is used to obtain the internal functions of the application to be tested based on the JAVA reflection characteristics, configure the calling functions of each page of the application to be tested through the Lua language, and build a Lua test script;

[0065] The script delivery module is used to deliver the Lua test script to one or more devices under test installed with the application to be tested through the network;

[0066] The test startup module is used to start the test, perform the device restart operation, and obtain the relevant parameters of the device startup through the Lua script. Specifically, the pre-set test mode flag is turned on on the device to be tested, the test is started, the device restart operation is performed, and the underlying Linux command is called through the Lua script to query the relevant parameters of the device startup;

[0067] The application testing module is used to open the corresponding page of the application to be tested through the page call function and calculate the rendering time of each page;

[0068] The result output module is used to generate and output the test results according to the acquired device startup related parameters and the rendering time of each page.

[0069] Preferably, in the test start module, the test is started by turning on a pre-set test mode identifier on the device to be tested, and the test mode identifier is hidden in the application software to be tested for the tester to switch the switch.

[0070] Preferably, in the application testing module, the rendering time of each page is calculated by: jumping the current page to the page corresponding to the calling function through the page calling function, and then grabbing the preset embedding data through the Lua script.

[0071] The buried point data includes: the first time point of triggering the page call function, and the second time point of the page rendering corresponding to the call function, and the page rendering time is calculated by the first time point and the second time point. The present invention does not use the conventional positioning element method for testing. The method realizes the mutual call with the code function of the device application through the Lua script, and completes the flexible jump and detection of the corresponding page through the page call function; such as: when the application software to be tested is a song ordering system, the song ordering system includes multiple pages such as singers and songs. After the jump is completed, the logcat buried point log is captured by the Lua script to calculate the display time of each page, repeat 10 times, and take the average value to obtain a more accurate performance time. In this way, there is no need to consider the layout and coordinate distribution of the device application UI interface. Due to the embeddability and lightweight characteristics of Lua, it is more convenient to obtain device applications and related parameters, and the running loss of the device is small. At the same time, because there is no coupling between the script and the device application code, the Lua script can be modified and adjusted at any time according to different needs or test results and retested.

[0072] Preferably, after the Lua test script is sent to the device to be tested, it is stored in a storage path under the device memory card according to a predefined storage path.

[0073] Preferably, the device startup related parameters include at least one of the following: the time from when the device is powered on to when the application to be tested runs normally (the boot startup running time of the underlying system can be obtained by embedding points, and the boot startup time is mainly used to calculate the startup time), the memory idle rate and the CPU idle rate after the device is started. The CPU idle rate is obtained by reading the CPU idle rate 10 times after the device is started and calculating its average value, which can obtain more accurate device-related startup parameters.

[0074] Since the system introduced in the second embodiment of the present invention is a system used to implement the method of the first embodiment of the present invention, those skilled in the art can understand the specific structure and deformation of the device based on the method introduced in the first embodiment of the present invention, so it is not described here in detail. All devices used in the method of the first embodiment of the present invention belong to the scope of protection of the present invention.

[0075] Based on the same inventive concept, the present application provides a storage medium corresponding to Example 1, see Example 3 for details.

[0076] Embodiment 3

[0077] This embodiment provides a computer-readable storage medium, such as Figure 3 As shown, a computer program is stored thereon, and when the computer program is executed by a processor, any implementation method in Example 1 can be implemented.

[0078] The technical solution provided in the embodiments of the present application has at least the following technical effects or advantages:

[0079] During the test process of the present invention, when the device is restarted, the test script can be automatically triggered without manual intervention, which ensures the continuity of the test and can more accurately obtain the relevant parameters of the device startup, significantly improves the efficiency of the test, reduces labor costs, reduces the investment of manpower and material resources, and optimizes resource allocation; through switch control and automatic triggering mechanism, the test process is more flexible, and can quickly respond to changes in business needs, while also ensuring that the trigger script execution is avoided in the non-testing stage; multiple repeated tests and accurate performance parameter records can be achieved, and the generated test result report provides strong support for subsequent performance analysis and optimization; the automated test of the present invention realizes decoupling from the business process and improves the adaptability and scalability of the system. In addition, the test script of the present invention only needs a network connection for the sending process once, without the need for a long connection, and can also be directly embedded in the device application. After the script is successfully pushed, compared with conventional automated testing, the entire test process no longer depends on the network connection, thereby avoiding the impact of network fluctuations and improving test stability.

[0080] Although the specific implementation modes of the present invention are described above, those skilled in the art should understand that the specific implementation modes described are only illustrative and are not intended to limit the scope of the present invention. Equivalent modifications and changes made by those skilled in the art in accordance with the spirit of the present invention should be included in the scope of protection of the claims of the present invention.

Claims

1. An automated testing method based on Lua script, characterized in that: The steps include: Step S1, obtaining the internal functions of the application to be tested according to the JAVA reflection characteristics, configuring the calling functions of each page of the application to be tested through the Lua language, and constructing a Lua test script; Step S2: Send the Lua test script to one or more devices to be tested installed with the application to be tested via the network; Step S3: Start the test, execute the device restart operation, and obtain the relevant parameters of the device startup through the Lua script; Step S4: Open the corresponding page of the application to be tested through the page call function, and calculate the rendering time of each page; Step S5: Generate and output test results based on the acquired device startup related parameters and rendering time of each page.

2. The Lua script-based automated testing method according to claim 1, characterized in that: In step S3, the test is started by turning on a preset test mode flag on the device to be tested.

3. The Lua script-based automated testing method according to claim 1, wherein: In the step S4, the rendering time of each page is calculated specifically by: jumping the current page to the page corresponding to the calling function through the page calling function, and then grabbing the preset embedding data through the Lua script.

4. The Lua script-based automated testing method according to claim 1, wherein: After the Lua test script is sent to the device to be tested, it is stored in a storage path under the device memory card according to a predefined storage path.

5. The Lua script-based automated testing method according to claim 2, characterized in that: The test mode identifier is hidden in the application software to be tested, so that the tester can switch the switch.

6. The Lua script-based automated testing method according to claim 1, characterized in that: The device startup related parameters include at least one of the following: the time from when the device is powered on to when the application to be tested runs normally, and the memory idle rate and CPU idle rate after the device is started.

7. The Lua script-based automated testing method according to claim 3, characterized in that: The buried data includes: a first time point when a page calling function is triggered, and a second time point when the page rendering corresponding to the calling function is completed, and the page rendering time is calculated by the first time point and the second time point.

8. An automated testing system based on Lua scripts, characterized in that: include: The script construction module is used to obtain the internal functions of the application to be tested based on the JAVA reflection characteristics, configure the calling functions of each page of the application to be tested through the Lua language, and build a Lua test script; The script delivery module is used to deliver the Lua test script to one or more devices under test installed with the application to be tested through the network; The test startup module is used to start the test, perform device restart operations, and obtain relevant parameters for device startup through Lua scripts; The application testing module is used to open the corresponding page of the application to be tested through the page call function and calculate the rendering time of each page; The result output module is used to generate and output the test results according to the acquired device startup related parameters and the rendering time of each page.

9. The Lua script-based automated testing system according to claim 8, characterized in that: In the application testing module, the rendering time of each page is calculated specifically as follows: the current page is jumped to the page corresponding to the calling function through the page calling function, and then the preset embedding data is captured through the Lua script. The embedding data includes: the first time point when the page calling function is triggered, and the second time point when the page rendering corresponding to the calling function is completed. The page rendering time is calculated through the first time point and the second time point.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Application testing method, center control server, test terminal and system

    CN104461898A

  • Method and device for testing webpage performances

    CN106681926A

  • Performance test method, device, system and equipment and storage medium

    CN109977027A

  • Method for upgrading functions of android system

    CN110874226A

  • User interface performance test method and device, electronic equipment and readable storage medium

    CN112685305A