Application program testing method, device, electronic device, and storage medium
By obtaining and executing the attribute information of the control to be tested in the target business test process of the application, the problem of difficult to efficiently test multiple business lines and frequently iterated applications in the prior art is solved, automated testing and efficient user concurrent scenario testing are realized, and testing accuracy and efficiency are improved.
Patent Information
- Application Number
- CN202311279112.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-28
- Publication Date
- 2025-04-08
AI Technical Summary
It is difficult for the existing technology to efficiently test multiple business lines and frequently iterated applications, especially in a large number of users' concurrent scenarios, and automated testing cannot be achieved.
By obtaining the attribute information of the control to be tested in the target business test process, positioning and executing the target code, the test cases are automatically run and the test results of the application are generated.
It realizes automated testing of applications, improves testing efficiency, and can complete tests that are difficult to achieve by manual testing, especially in user concurrency scenarios. At the same time, through the attribute information positioning code of the control to be tested, it is suitable for devices with different resolutions, improving the test accuracy.
Smart Images

Figure CN119782132A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method, device, electronic equipment, and storage medium for testing an application. Background Art
[0002] At present, there are many business lines of various applications, and they will continue to iterate. Different applications have different business functions. Business testing of applications is generally done manually, which is cumbersome and cannot be implemented for a large number of concurrent user scenarios. Summary of the invention
[0003] The technical problem to be solved by the present invention is to overcome the above-mentioned defects in the prior art and to provide a method, device, electronic device and storage medium for testing an application.
[0004] The present invention solves the above technical problems through the following technical solutions:
[0005] In a first aspect, a method for testing an application is provided, wherein the application includes a user interface, and the user interface includes at least one control to be tested; the method includes:
[0006] Acquire a target business test process for the application, wherein the target business test process includes property information of at least one control to be tested and the target business test process corresponds to at least one target test case;
[0007] Running the target test case, so that the target test case locates the target code that implements the function of the control to be tested from the source code of the user interface according to the attribute information and executes the target code;
[0008] A test result of the application is generated according to the execution result of the target code.
[0009] Optionally, the target business test process includes at least one test node, the test node includes attribute information of at least one control to be tested, and each test node corresponds to at least one node test case; running the target test case includes:
[0010] Determine a target test case that matches each test node from a plurality of pre-set node test cases to form a test case set corresponding to the target business test process;
[0011] Run each target test case in the test case set.
[0012] Optionally, running each target test case in the test case set includes:
[0013] Determine the dependency relationship of each target test case according to the dependency relationship of each test node in the target business test process;
[0014] Determining the running order of each target test case according to the dependency relationship of each target test case;
[0015] According to the running order, the target test cases are run.
[0016] Optionally, it also includes:
[0017] In response to the test request, candidate test nodes are displayed; wherein each candidate test node is pre-configured with a corresponding node test case;
[0018] The selected candidate test nodes are combined into the target service test process.
[0019] Optionally, obtaining a target business test process for the application includes:
[0020] In the case where the source code is updated, determining the property information of the target control involved in the updated code;
[0021] A business test process including the attribute information of the target control among a plurality of pre-stored business test processes is determined as the target business test process.
[0022] Optionally, it also includes:
[0023] generating a code execution log, wherein the log is represented by text and / or images;
[0024] and / or, after running the target test case, deleting data generated by running the target test case;
[0025] and / or, in case the target test case fails to run, running the target test case again;
[0026] and / or, pre-storing environment configuration parameters for calling when the target test case is run;
[0027] And / or, pre-store test parameters for calling when the target test case is run.
[0028] In a second aspect, a testing device for an application is provided, wherein the application includes a user interface, and the user interface includes at least one control to be tested; the testing device includes:
[0029] An acquisition module, used to acquire a target business test process for the application, wherein the target business test process includes property information of at least one control to be tested and the target business test process corresponds to at least one target test case;
[0030] A running module, used for running the target test case, so that the target test case locates the target code that implements the function of the control to be tested from the source code of the user interface according to the attribute information and executes it;
[0031] A generation module generates a test result of the application program according to the execution result of the target code.
[0032] Optionally, the target business test process includes at least one test node, the test node includes attribute information of at least one control to be tested, and each test node corresponds to at least one node test case; the running module includes:
[0033] A first determining unit, configured to determine a target test case matching each test node from a plurality of pre-set node test cases, to form a test case set corresponding to the target business test process;
[0034] The running unit is used to run each target test case in the test case set.
[0035] Optionally, the operation module includes:
[0036] A second determining unit, configured to determine the dependency relationship of each target test case according to the dependency relationship of each test node in the target business test process;
[0037] A third determining unit, configured to determine the running order of each target test case according to the dependency relationship of each target test case;
[0038] The running unit is specifically used to run each target test case according to the running order.
[0039] Optionally, it also includes:
[0040] A display module, used to display candidate test nodes in response to a test request; wherein each candidate test node is pre-configured with a corresponding node test case;
[0041] The combination module is used to combine the selected candidate test nodes into the target business test process.
[0042] Optionally, the acquisition module includes:
[0043] A first determination module, configured to determine, when the source code is updated, the property information of the target control involved in the updated code;
[0044] The second determining module is used to determine a business test process containing the attribute information of the target control among the pre-stored multiple business test processes as the target business test process.
[0045] Optionally, it also includes:
[0046] A generation module, used for generating a code execution log, wherein the log is represented by text and / or image;
[0047] and / or, a deletion module, for deleting data generated by running the target test case after running the target test case;
[0048] and / or, a re-calling module, for re-running the target test case if the target test case fails to run;
[0049] and / or, a storage module, for pre-storing environment configuration parameters for calling when the target test case is run;
[0050] And / or, a storage module, used to pre-store test parameters for calling when the target test case is running.
[0051] According to a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the test method of the application program described in any one of the above items when executing the computer program.
[0052] In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the test method of the application program described in any one of the above items is implemented.
[0053] On the basis of being in accordance with the common sense in the art, the above-mentioned preferred conditions can be arbitrarily combined to obtain the preferred embodiments of the present invention.
[0054] The positive and progressive effect of the present invention is that the present invention completes the automatic test of the target business test process by sequentially locating and executing the code of the control to be tested of each test node in the target business test process, with high test efficiency, and can complete some tests that are quite difficult or impossible to perform manually. In addition, during the test process, the target code of the control to be tested is located by the attribute information of the control to be tested, that is, the positioning of the control to be tested and the target business test process and test case are separated, so that the test method is suitable for testing application programs in various types of devices with different resolutions, and there will be no accidental touch of the control due to different device resolutions, which can improve the test accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1The present invention is a flowchart of a method for testing an application program according to an exemplary embodiment of the present invention.
[0056] Figure 2 for Figure 1 Specific flow chart of step 102 in FIG.
[0057] Figure 3 A module diagram of a system for testing an application program provided by an exemplary embodiment of the present invention.
[0058] Figure 4 The present invention is a schematic structural diagram of an electronic device according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0059] The present invention is further described below by way of examples, but the present invention is not limited to the scope of the examples.
[0060] Figure 1 A flowchart of a method for testing an application provided by an exemplary embodiment of the present invention, wherein the application includes a user interface, and the user interface includes at least one control to be tested. Figure 1 , the test method includes the following steps:
[0061] Step 101: Obtain a target business test process for an application program, where the target business test process includes property information of at least one control to be tested and the target business test process corresponds to at least one target test case.
[0062] The target business test process can be designed by yourself according to the target business test process that can realize the corresponding function. For example, to test the login function of the application, the target business test process includes: start the application → obtain the account password → trigger the login control. The target business test process involves 2 controls to be tested, namely the input box control and the login control. For another example, to test the product details display function of the application, the target business test process includes: click the product image on the product page → the page jumps to the product details page, and the control to be tested is the product image trigger control. For another example, the target business test process includes: login → search for "computer" → click the product image → purchase → payment.
[0063] The property information of the control to be tested may include, but is not limited to, a control identifier and layout information of the control to be tested. The layout information includes the position of the control to be tested in the user interface and / or the relative position relationship between the control to be tested and other controls.
[0064] Step 102: Run the target test case, so that the target test case locates the target code that implements the function of the control to be tested from the source code of the user interface according to the attribute information and executes it.
[0065] The target test case is used to locate and execute the code of the control to be tested, trigger the control, and thus simulate the action of manually clicking the control without manual operation.
[0066] Step 103: Generate a test result of the application program according to the execution result of the target code.
[0067] Specifically, if the execution result of the target code matches the expected result, the test result of the application is a test pass; if the execution result of the target code does not match the expected result, the test result of the application is a test fail.
[0068] In one embodiment, the user interface displayed after the target code is executed is used as the execution result. When generating the test result, the user interface displayed after the target code is executed is intercepted, and the similarity between the user interface displayed after the target code is executed and the user interface (pre-set) representing the expected result is determined. If the similarity is greater than a similarity threshold, it is determined that the execution result of the target code matches the expected result, otherwise it is determined that the execution result of the target code does not match the expected result. The similarity threshold can be set according to the actual situation.
[0069] In one embodiment, the results of the parameters involved in the target code are determined as the execution results of the target code. Taking the target business test process including login→search for "computer"→click on the product picture→purchase→payment as an example, the target code involves a payment amount. If the payment amount is equal to the amount deducted from the user account after executing the target code, it is determined that the execution result of the target code matches the expected result, otherwise it is determined that the execution result of the target code does not match the expected result.
[0070] In the embodiment of the present invention, the automatic test of the target business test process is completed by sequentially locating the code of the control to be tested of each test node in the target business test process and executing it, and the test efficiency is high, and some tests that are quite difficult or impossible to perform manually can be completed, such as a large number of concurrent user tests. In addition, the target code of the control to be tested is located through the attribute information of the control to be tested during the test process, that is, the positioning of the control to be tested and the target business test process and test case are separated, so that the test method is suitable for testing applications in various types of devices with different resolutions, and there will be no accidental touch of the control due to different device resolutions, which can improve the test accuracy.
[0071] In one embodiment, the target business test process includes at least one test node, the test node includes attribute information of at least one control to be tested, and each test node corresponds to at least one node test case; the step of running the target test case includes: determining the target test case matching each test node from a plurality of pre-set node test cases, forming a test case set corresponding to the target business test process, and running each target test case in the test case set.
[0072] In an embodiment of the present invention, a correspondence between each test node and a node test case is pre-set, and the test case set to be run is determined according to the correspondence during testing, so that users can build a target business test process according to their needs, meet the testing needs of various applications, have good universality, and are easy to maintain later.
[0073] In one embodiment, see Figure 2 , the steps to run each target test case in the test case set include:
[0074] Step 102 - 1 : Determine the dependency relationship of each target test case according to the dependency relationship of each test node in the target business test process.
[0075] Step 102-2: Determine the running order of each target test case according to the dependency relationship of each target test case.
[0076] Step 103-3: Run each target test case according to the running order.
[0077] For example, the target business test process includes nodes a, b and c, and the dependency relationship is that the execution of nodes b and c depends on the execution result of node a, node a corresponds to test case A, node b corresponds to test case B, node c corresponds to test case C, test cases B and C depend on the execution result of test case A, and test case B and test case C have no dependency relationship with each other, so the running order of the three test cases is to run test case A first, and then run test case B and test case C. Among them, the running order of test case B and test case C can be run synchronously, and test case B can be run first and then test case C, or test case C can be run first and then test case B, and there is no special limitation on this.
[0078] In an embodiment of the present invention, the running order of the target test cases is determined according to the dependency relationship of each test node in the target business test process, and each target test case is run according to the running order, which can ensure the orderly and effective running of the target test cases, thereby ensuring the effective execution of the application program test and improving the test efficiency.
[0079] In one embodiment, in response to a test request, candidate test nodes are displayed, and selected candidate test nodes are combined into a target business test process. Each candidate test node is pre-configured with a corresponding node test case.
[0080] In the embodiment of the present invention, since the correspondence between candidate test nodes and node test cases is preset, the user does not need to pay attention to the underlying logic of the test, but only needs to select the target business test process required by the test node composition, which can realize the test of the application and is easy to operate.
[0081] Regarding the testing timing of the application, in one embodiment, when it is determined that the source code of the application is updated, the attribute information of the target control involved in the updated code is determined, and a business test process that contains the attribute information of the target control among multiple pre-stored business test processes is determined as the target business test process.
[0082] Since the application will be continuously updated and iterated, each update may affect the old functions of the previous software. Therefore, in the embodiment of the present invention, each time the source code of the application is updated, the controls involved in the updated code are determined, and the business test process containing the controls is selected as the target business test process to test the application, thereby enabling automated regression testing of the application, which is convenient and reliable, can be tested in time, problems can be discovered early, and testing efficiency is improved to ensure the quality of each iterative version of the application.
[0083] In one embodiment, the method further generates a code execution log, which is represented by text and / or images. The code execution log facilitates subsequent review of the test process and reasons, and determines the historical traceability of the test data.
[0084] In one embodiment, after the target test case is run, the data generated by running the target test case is deleted to avoid the impact of the test data on the actual data.
[0085] In one embodiment, if the target test case fails to run, the target test case is run again. For example, if the application crashes and the test case fails to run successfully, it will be run again to avoid the test being affected by short-term network fluctuations and ensure that the test proceeds smoothly.
[0086] In one embodiment, an upper limit value may be set for the number of times a target test case is run again. If the number of times a target test case is run again reaches the upper limit value, the test case will no longer be run and a test failure prompt will be generated to prompt the operation and maintenance personnel to perform repairs in a timely manner.
[0087] In one embodiment, environmental configuration parameters are pre-stored for calling when the target test case is run to ensure that the test is carried out smoothly.
[0088] In one embodiment, test parameters are stored in advance for calling when the target test case is run. Test parameters include user login account password, payment amount, etc. Test parameters are stored in advance for calling when the target test case is run to ensure that the test is carried out smoothly.
[0089] Corresponding to the aforementioned application program testing method embodiment, the present invention also provides an application program testing device embodiment.
[0090] Figure 3 A module diagram of a testing device for an application provided by an exemplary embodiment of the present invention, wherein the application includes a user interface, and the user interface includes at least one control to be tested; the testing device includes:
[0091] An acquisition module 31 is used to acquire a target business test process for the application, wherein the target business test process includes property information of at least one control to be tested and the target business test process corresponds to at least one target test case;
[0092] A running module 32, used for running the target test case, so that the target test case locates the target code that implements the function of the control to be tested from the source code of the user interface according to the attribute information and executes it;
[0093] The generating module 33 generates the test result of the application program according to the execution result of the target code.
[0094] Optionally, the target business test process includes at least one test node, the test node includes attribute information of at least one control to be tested, and each test node corresponds to at least one node test case; the running module includes:
[0095] A first determining unit, configured to determine a target test case matching each test node from a plurality of pre-set node test cases, to form a test case set corresponding to the target business test process;
[0096] The running unit is used to run each target test case in the test case set.
[0097] Optionally, the operation module includes:
[0098] A second determining unit, configured to determine the dependency relationship of each target test case according to the dependency relationship of each test node in the target business test process;
[0099] A third determining unit, configured to determine the running order of each target test case according to the dependency relationship of each target test case;
[0100] The running unit is specifically used to run each target test case according to the running order.
[0101] Optionally, it also includes:
[0102] A display module, used to display candidate test nodes in response to a test request; wherein each candidate test node is pre-configured with a corresponding node test case;
[0103] The combination module is used to combine the selected candidate test nodes into the target business test process.
[0104] Optionally, the acquisition module includes:
[0105] A first determination module, configured to determine, when the source code is updated, the property information of the target control involved in the updated code;
[0106] The second determining module is used to determine a business test process containing the attribute information of the target control among the pre-stored multiple business test processes as the target business test process.
[0107] Optionally, it also includes:
[0108] A generation module, used for generating a code execution log, wherein the log is represented by text and / or image;
[0109] and / or, a deletion module, for deleting data generated by running the target test case after running the target test case;
[0110] and / or, a re-calling module, for re-running the target test case if the target test case fails to run;
[0111] and / or, a storage module, for pre-storing environment configuration parameters for calling when the target test case is run;
[0112] And / or, a storage module, used to pre-store test parameters for calling when the target test case is running.
[0113] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of the present invention. Ordinary technicians in this field can understand and implement it without paying creative work.
[0114] Figure 4 The schematic diagram of the structure of an electronic device according to an exemplary embodiment of the present invention shows a block diagram of an exemplary electronic device 40 suitable for implementing the embodiment of the present invention. Figure 4 The electronic device 40 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0115] like Figure 4 As shown, the electronic device 40 may be in the form of a general-purpose computing device, for example, it may be a server device. The components of the electronic device 40 may include, but are not limited to: at least one processor 41, at least one memory 42, and a bus 43 connecting different system components (including the memory 42 and the processor 41).
[0116] The bus 43 includes a data bus, an address bus, and a control bus.
[0117] The memory 42 may include a volatile memory, such as a random access memory (RAM) 421 and / or a cache memory 422 , and may further include a read-only memory (ROM) 423 .
[0118] The memory 42 may also include a program tool 425 (or utility) having a set (at least one) of program modules 424, such program modules 424 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0119] The processor 41 executes various functional applications and data processing by running the computer program stored in the memory 42, such as the method provided in any of the above embodiments.
[0120] The electronic device 40 may also communicate with one or more external devices 44 (e.g., keyboards, pointing devices, etc.). Such communication may be performed via an input / output (I / O) interface 45. Furthermore, the model-generated electronic device 40 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 46. As shown, the network adapter 46 communicates with other modules of the model-generated electronic device 40 via a bus 43. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the model-generated electronic device 40, including but not limited to: microcode, device drivers, redundant processors, external disk drive arrays, RAID (disk array) systems, tape drives, and data backup storage systems, etc.
[0121] It should be noted that although several units / modules or sub-units / modules of the electronic device are mentioned in the above detailed description, this division is merely exemplary and not mandatory. In fact, according to an embodiment of the present invention, the features and functions of two or more units / modules described above can be embodied in one unit / module. Conversely, the features and functions of one unit / module described above can be further divided into multiple units / modules to be embodied.
[0122] An embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the program is executed by a processor, the method provided by any of the above embodiments is implemented.
[0123] The readable storage medium may include but is not limited to: a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical storage device, a magnetic storage device or any suitable combination of the above.
[0124] In a possible implementation manner, the embodiment of the present invention may also be implemented in the form of a program product, which includes a program code. When the program product is run on a terminal device, the program code is used to enable the terminal device to execute a method for implementing any of the above embodiments.
[0125] The program code for executing the present invention may be written in any combination of one or more programming languages, and may be executed entirely on a user device, partially on a user device, as an independent software package, partially on a user device and partially on a remote device, or entirely on a remote device.
[0126] Although the specific embodiments of the present invention are described above, it should be understood by those skilled in the art that this is only for illustration and the protection scope of the present invention is defined by the appended claims. Those skilled in the art may make various changes or modifications to these embodiments without departing from the principles and essence of the present invention, but these changes and modifications all fall within the protection scope of the present invention.
Claims
1. A method for testing an application, characterized in that: The application includes a user interface, and the user interface includes at least one control to be tested; the testing method includes: Acquire a target business test process for the application, wherein the target business test process includes property information of at least one control to be tested and the target business test process corresponds to at least one target test case; Running the target test case, so that the target test case locates the target code that implements the function of the control to be tested from the source code of the user interface according to the attribute information and executes the target code; A test result of the application is generated according to the execution result of the target code.
2. The application testing method according to claim 1, characterized in that: The target business test process includes at least one test node, the test node includes attribute information of at least one control to be tested, and each test node corresponds to at least one node test case; Run the target test cases, including: Determine a target test case that matches each test node from a plurality of pre-set node test cases to form a test case set corresponding to the target business test process; Run each target test case in the test case set.
3. The application testing method according to claim 2, characterized in that: Run each target test case in the test case set, including: Determine the dependency relationship of each target test case according to the dependency relationship of each test node in the target business test process; Determining the running order of each target test case according to the dependency relationship of each target test case; According to the running order, the target test cases are run.
4. The application testing method according to claim 2, characterized in that: Also includes: In response to the test request, candidate test nodes are displayed; wherein each candidate test node is pre-configured with a corresponding node test case; The selected candidate test nodes are combined into the target service test process.
5. The application testing method according to claim 1, characterized in that: Get the target business test flow for the application, including: In the case where the source code is updated, determining the property information of the target control involved in the updated code; A business test process including the attribute information of the target control among a plurality of pre-stored business test processes is determined as the target business test process.
6. The application testing method according to claim 1, characterized in that: Also includes: generating a code execution log, wherein the log is represented by text and / or images; and / or, after running the target test case, deleting data generated by running the target test case; and / or, in case the target test case fails to run, running the target test case again; and / or, pre-storing environment configuration parameters for calling when the target test case is run; And / or, pre-store test parameters for calling when the target test case is run.
7. A testing device for an application, characterized in that: The application comprises a user interface, and the user interface comprises at least one control to be tested; the testing device comprises: An acquisition module, used to acquire a target business test process for the application, wherein the target business test process includes property information of at least one control to be tested and the target business test process corresponds to at least one target test case; A running module, used for running the target test case, so that the target test case locates the target code that implements the function of the control to be tested from the source code of the user interface according to the attribute information and executes it; A generation module generates a test result of the application program according to the execution result of the target code.
8. The application testing device according to claim 7, characterized in that: The target business test process includes at least one test node, the test node includes attribute information of at least one control to be tested, and each test node corresponds to at least one node test case; The operation module includes: A first determining unit, configured to determine a target test case matching each test node from a plurality of pre-set node test cases, to form a test case set corresponding to the target business test process; The running unit is used to run each target test case in the test case set.
9. The application testing device according to claim 8, characterized in that: The operation module includes: A second determining unit, configured to determine the dependency relationship of each target test case according to the dependency relationship of each test node in the target business test process; A third determining unit, configured to determine the running order of each target test case according to the dependency relationship of each target test case; The running unit is specifically used to run each target test case according to the running order.
10. The application testing device according to claim 8, characterized in that: Also includes: A display module, used to display candidate test nodes in response to a test request; wherein each candidate test node is pre-configured with a corresponding node test case; The combination module is used to combine the selected candidate test nodes into the target business test process.
11. The application testing device according to claim 7, characterized in that: The acquisition module comprises: A first determination module, configured to determine, when the source code is updated, the property information of the target control involved in the updated code; The second determining module is used to determine a business test process containing the attribute information of the target control among the pre-stored multiple business test processes as the target business test process.
12. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for testing the application program according to any one of claims 1 to 6 is implemented.
13. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method for testing the application program according to any one of claims 1 to 6 is implemented.