Execution method of test case, computer program product and electronic equipment
By storing test steps in reverse order and using a custom stack structure to implement hierarchical execution, the problem of low test case execution efficiency is solved, improving efficiency and reducing memory usage.
Patent Information
- Application Number
- CN202410863810.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-29
- Publication Date
- 2024-10-01
AI Technical Summary
In existing test case automation execution methods, the execution efficiency of nested test cases is low, resulting in large memory consumption and low efficiency.
By storing test steps in reverse order into the initial stack, and using a custom stack structure to implement hierarchical execution of the test case tree, recursive calls are avoided and memory usage is reduced.
It improves the execution efficiency of test cases, reduces memory usage, and avoids high memory consumption problems caused by recursive calls.
Smart Images

Figure CN118733464A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of test cases, and in particular to a test case execution method, a computer-readable storage medium, a computer program product, and an electronic device. Background Art
[0002] The existing test case automation execution method adopts the method of recursive calling of the execution method to solve the problem of executing test cases with nested structures. When there are too many test case levels, it will generate large memory consumption, resulting in low execution efficiency. Summary of the invention
[0003] The main purpose of the present application is to provide a test case execution method, a computer-readable storage medium, a computer program product and an electronic device, so as to at least solve the problem of low test case execution efficiency in the prior art.
[0004] In order to achieve the above-mentioned purpose, according to one aspect of the present application, a method for executing a test case is provided, the test case comprising a plurality of test steps arranged in sequence and at least one sub-test step corresponding to some of the test steps, the test step corresponding to the sub-test step is a target test step, and the test order of the sub-test step is located after the test of the corresponding target test step, the method comprising: a first storage step, storing the plurality of the test steps in reverse order into an initial stack to obtain a first stack; a first response step, in response to a first trigger signal, calling a test execution module to execute the test step corresponding to the pointing rule of a first pointer node to obtain a first test report, the first pointer node being used to point to the test step corresponding to the top of the first stack, the test report The test execution module is used to execute the test case; the first determination step is to determine whether the test step corresponding to the top of the first stack is the target test step; the second storage step is to store the sub-test steps corresponding to the target test step in the first stack in reverse order to obtain a second stack when the test step corresponding to the top of the first stack is the target test step; the second response step is to call the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node in response to a second trigger signal to obtain a second test report, wherein the second pointer node is used to point to the sub-test step corresponding to the top of the second stack; the generation step is to generate a final test report of the test case according to the first test report and the second test report.
[0005] Optionally, before the first response step, the method also includes: obtaining the first pointer node and the first root node of the target linked list, the target linked list being used to store the first test report; generating a pointer to the target linked list; pointing the first pointer node to the first root node, and pointing the pointer of the target linked list to the first pointer node to generate the first trigger signal, calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to obtain the first test report, including: calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to generate the first test report in the target linked list.
[0006] Optionally, after the second storage step and before the second response step, the method also includes: obtaining the second pointer node and the second root node of the target linked list, the target linked list is used to store the second test report, and the second root node is the root node of the target linked list other than the first root node; pointing the second pointer node to the second root node, and pointing the pointer of the target linked list to the second pointer node to generate the second trigger signal, calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node, and obtaining the second test report, including: calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list.
[0007] Optionally, calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to generate the first test report in the target linked list includes: calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to obtain the first test report; storing the first test report to the position corresponding to the node after the node pointed to by the first pointer node in the target linked list.
[0008] Optionally, calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list includes: calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain the second test report; storing the second test report to the position corresponding to the node after the node pointed to by the second pointer node in the target linked list.
[0009] Optionally, after the second response step and before the generation step, the method further includes: a second determination step, determining whether the number of the sub-test steps remaining in the second stack is 0; and a first loop step, when the number of the sub-test steps remaining in the second stack is not 0, looping the second response step and the second determination step until the number of the sub-test steps remaining in the second stack is 0.
[0010] Optionally, before the generating step, the method further includes: a third determining step, determining whether the number of the test steps remaining in the first stack is 0; a pointing step, when the number of the sub-test steps remaining in the second stack is 0, pointing the pointer of the target linked list to the first pointer node to generate the first trigger signal; and a second looping step, when the number of the test steps remaining in the first stack is not 0, looping the pointing step and the first responding step until the number of the test steps remaining in the first stack is 0.
[0011] According to another aspect of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium includes a stored program, wherein when the program is run, the device where the computer-readable storage medium is located is controlled to execute any one of the test case execution methods.
[0012] According to another aspect of the present application, a computer program product is provided, comprising computer instructions, wherein when the computer instructions are executed by a processor, any one of the test case execution methods is implemented.
[0013] According to another aspect of the present application, an electronic device is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an execution method for executing any one of the test cases.
[0014] By applying the technical solution of the present application, multiple test steps are first stored in an initial stack to obtain a first stack, and then in response to a first trigger signal, a test execution module is called to execute the test step corresponding to the pointing rule of the first pointer node to obtain a first test report, wherein the first pointer node is used to point to the test step corresponding to the top of the first stack, and then determine whether the test step corresponding to the top of the first stack corresponds to a sub-test step (that is, whether it is a target test step), and when it is a target test step, the sub-test step corresponding to the target test step is stored in the first stack in reverse order to obtain a second stack, and then in response to a second trigger signal, the test execution module is called to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain a second test report, and the second pointer node is used to point to the sub-test step corresponding to the top of the second stack, and finally, a final test report of the test case is generated according to the first test report and the second test report. Compared with the prior art that uses recursive calls to execute test cases, which generates large memory consumption and leads to low execution efficiency, the present application stores multiple test steps in an initial stack in reverse order to obtain a first stack, and executes the test step corresponding to the top of the first stack to obtain a first test report. When there is a corresponding sub-test step for the test step corresponding to the top of the first stack, the corresponding sub-test step is stored in the first stack in reverse order to obtain a second stack, and the sub-test step corresponding to the top of the second stack is executed to obtain a second test report. That is, the hierarchical execution of the test case tree is realized by using a custom stack structure, which avoids recursive calls of the test case execution method, thereby avoiding the problem of excessive memory usage, and further ensuring high execution efficiency of the test cases. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The drawings constituting part of the present application are used to provide a further understanding of the present application. The exemplary embodiments and descriptions of the present application are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0016] Figure 1 A hardware structure block diagram of a mobile terminal for executing a test case execution method provided in an embodiment of the present application is shown;
[0017] Figure 2 A schematic diagram of a flow chart of a method for executing a test case provided according to an embodiment of the present application is shown;
[0018] Figure 3 A schematic diagram of the organization of a test case provided according to an embodiment of the present application is shown;
[0019] Figure 4 The execution method of the test case of the present application is shown Figure 3 Schematic diagram of the stack data changes during the execution of the test case;
[0020] Figure 5 The execution method of the test case of the present application is shown Figure 3 Schematic diagram of test report generation during the execution of test cases in;
[0021] Figure 6 A flowchart of a specific test case execution method provided according to an embodiment of the present application is shown.
[0022] The above drawings include the following reference numerals:
[0023] 102, processor; 104, memory; 106, transmission device; 108, input and output devices. DETAILED DESCRIPTION
[0024] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present application described here. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] As introduced in the background technology, the test case execution efficiency in the prior art is low. To solve the above problem, the embodiments of the present application provide a test case execution method, a computer-readable storage medium, a computer program product and an electronic device.
[0028] The technical solutions in the embodiments of the present invention will be described clearly and completely below in conjunction with the accompanying drawings in the embodiments of the present invention.
[0029] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 FIG. 1 is a hardware structure diagram of a mobile terminal for executing a test case according to an embodiment of the present invention. Figure 1 As shown, the mobile terminal may include one or more ( Figure 1 Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data, wherein the mobile terminal may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.
[0030] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as computer programs corresponding to the execution method of the test case in the embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, the above method is implemented. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. The transmission device 106 is used to receive or send data via a network. The above-mentioned specific examples of the network may include a wireless network provided by a communication provider of the mobile terminal. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0031] In this embodiment, a method for executing a test case running on a mobile terminal, a computer terminal or a similar computing device is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0032] Figure 2 is a flow chart of a method for executing a test case according to an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:
[0033] Step S201, a first storage step, storing the plurality of the above test steps in reverse order into an initial stack to obtain a first stack;
[0034] Specifically, the test step at the top of the initial stack is the test step at the last position in the sorting, and the test step at the bottom of the initial stack is the test step at the first position in the sorting.
[0035] Step S202, a first response step, in response to a first trigger signal, calling a test execution module to execute the test step corresponding to the pointing rule of the first pointer node to obtain a first test report, wherein the first pointer node is used to point to the test step corresponding to the top of the first stack, and the test execution module is used to execute the test case;
[0036] Step S203, a first determination step, determining whether the test step corresponding to the top of the first stack is the target test step;
[0037] Step S204, a second storage step, in which, when the test step corresponding to the top of the first stack is the target test step, the sub-test steps corresponding to the target test step are stored in the first stack in reverse order to obtain a second stack;
[0038] Step S205, a second response step, in response to a second trigger signal, calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain a second test report, wherein the second pointer node is used to point to the sub-test step corresponding to the top of the second stack;
[0039] Step S206, a generating step, generates a final test report of the test case according to the first test report and the second test report.
[0040] Through the above embodiment, multiple test steps are first stored in an initial stack to obtain a first stack, and then in response to a first trigger signal, the test execution module is called to execute the test step corresponding to the pointing rule of the first pointer node to obtain a first test report, wherein the first pointer node is used to point to the test step corresponding to the top of the first stack, and then determine whether the test step corresponding to the top of the first stack corresponds to a sub-test step (that is, whether it is a target test step), and when it is a target test step, the sub-test step corresponding to the target test step is stored in the first stack in reverse order to obtain a second stack, and then in response to a second trigger signal, the test execution module is called to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain a second test report, and the second pointer node is used to point to the sub-test step corresponding to the top of the second stack, and finally, according to the first test report and the second test report, a final test report of the test case is generated. Compared with the prior art that uses recursive calls to execute test cases, which generates large memory consumption and leads to low execution efficiency, the present application stores multiple test steps in an initial stack in reverse order to obtain a first stack, and executes the test step corresponding to the top of the first stack to obtain a first test report. When there is a corresponding sub-test step for the test step corresponding to the top of the first stack, the corresponding sub-test step is stored in the first stack in reverse order to obtain a second stack, and the sub-test step corresponding to the top of the second stack is executed to obtain a second test report. That is, the hierarchical execution of the test case tree is realized by using a custom stack structure, which avoids recursive calls of the test case execution method, thereby avoiding the problem of excessive memory usage, and further ensuring high execution efficiency of the test cases.
[0041] Specifically, the initial stack is initialized first, and then the plurality of test steps are stored in reverse order into the initialized initial stack.
[0042] Specifically, after calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node, the executed test steps are deleted from the initial stack, and the test steps located after the executed test steps in the initial stack are replaced in sequence.
[0043] Specifically, the above test steps are stored in the form of a sequence list + linked list. The organization form of the above test cases is as follows: Figure 3 As shown, the test step node of the first-level sequence table stores multiple test steps arranged in sequence (i.e., test steps of the same level), and the sub-test step node of the second-level sequence table stores sub-test steps corresponding to the target test step, and the target test step contains a pointer to the second-level sequence table.
[0044] Specifically, Figure 3As shown, the test step node of the first level sequence table stores 10 test steps arranged in sequence, and the sub-test step node of the second level sequence table stores 3 sub-test steps corresponding to the target test step; Figure 3 The numbers in each node represent the number of remaining nodes at the same level. For example, "9" means that the number of remaining nodes after the node at 9 in the first-level sequence table is 9. The meanings of the remaining numbers are similar and will not be repeated here.
[0045] Specifically, the basic structures of the test step node and the sub-test step node include: a parameter list, the number of remaining nodes at the same level, and a list element pointing to the head node of the sub-link list.
[0046] In an optional solution, before the first response step, the method further includes: obtaining the first pointer node and the first root node of the target linked list, the target linked list is used to store the first test report; generating a pointer to the target linked list; pointing the first pointer node to the first root node, and pointing the pointer of the target linked list to the first pointer node, to generate the first trigger signal, calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node, and obtaining the first test report, including: calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node, to generate the first test report in the target linked list. In this embodiment, the first pointer node and the first root node of the target linked list are obtained, the pointer of the target linked list is generated, the first pointer node is pointed to the first root node, and the pointer of the target linked list is pointed to the first pointer node, to generate the first trigger signal, to prepare for the subsequent first response step, and the structure of the linked list is used to store the first test report, the hierarchical structure of the test case is retained, and the readability of the final test report is ensured to be high.
[0047] Specifically, the first root node is obtained and initialized. Specifically, the first pointer node is added to a new auxiliary queue node.
[0048] In other embodiments, after generating the first trigger signal and before the first response step, the method further includes: taking out the test step corresponding to the top of the first stack from the first stack.
[0049] According to some exemplary embodiments of the present application, after the second storage step and before the second response step, the method further includes: obtaining the second pointer node and the second root node of the target linked list, the target linked list is used to store the second test report, and the second root node is the root node of the target linked list except the first root node; the second pointer node points to the second root node, and the pointer of the target linked list points to the second pointer node to generate the second trigger signal, and the test execution module is called to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain the second test report, including: calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list. In this embodiment, the second pointer node and the second root node of the target linked list are obtained, the second pointer node points to the second root node, and the pointer of the target linked list points to the second pointer node to generate the second trigger signal, so as to prepare for the subsequent second response step, and the structure of the linked list is used to store the second test report, which further retains the hierarchical structure of the test case and further ensures the high readability of the final test report.
[0050] Specifically, the second root node is generated, and the child node pointer corresponding to the first test report is made to point to the second root node. Specifically, the second pointer node is added to the auxiliary node queue.
[0051] In other embodiments, after generating the second trigger signal and before the second response step, the method further includes: taking out the sub-test step corresponding to the top of the second stack from the second stack.
[0052] According to some other exemplary embodiments of the present application, calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to generate the first test report in the target linked list includes: calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to obtain the first test report; storing the first test report in the target linked list at a position corresponding to the node after the node pointed to by the first pointer node. In this embodiment, the test execution module is first called to execute the test steps corresponding to the top of the first stack to obtain the first test report, and then the first test report is stored in the target linked list at a position corresponding to the node after the node pointed to by the first pointer node, which further ensures that the final test report has a high readability.
[0053] In other embodiments, the test execution module is called to execute the sub-test step corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list, including: calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain the second test report; storing the second test report in the target linked list at a position corresponding to the node after the node pointed to by the second pointer node. In this embodiment, the test execution module is first called to execute the sub-test step corresponding to the top of the first stack to obtain the second test report, and then the second test report is stored in the target linked list at a position corresponding to the node after the node pointed to by the second pointer node, which further ensures that the final test report has a high readability.
[0054] In some other optional schemes of the present application, after the second response step and before the generation step, the method further includes: a second determination step, determining whether the number of the sub-test steps remaining in the second stack is 0; and a first loop step, in the case where the number of the sub-test steps remaining in the second stack is not 0, looping the second response step and the second determination step until the number of the sub-test steps remaining in the second stack is 0. In this embodiment, in the case where the number of sub-test steps remaining in the second stack is not 0, the second response step and the second determination step are looped until the number of sub-test steps remaining in the second stack is 0, and the remaining sub-test steps are executed by continuously looping, which further ensures that the occupied memory space is small, and further ensures that the execution efficiency of the test case is high.
[0055] In some other optional schemes of the present application, before the generation step, the method further includes: a third determination step, determining whether the number of the test steps remaining in the first stack is 0; a pointing step, when the number of the sub-test steps remaining in the second stack is 0, pointing the pointer of the target linked list to the first pointer node to generate the first trigger signal; a second loop step, when the number of the test steps remaining in the first stack is not 0, looping the pointing step and the first response step until the number of the test steps remaining in the first stack is 0. In this embodiment, when the number of sub-test steps remaining in the second stack is 0, the pointer of the target linked list is pointed to the first pointer node to generate the first trigger signal, and when the number of test steps remaining in the first stack is not 0, looping the pointing step and the first response step until the number of test steps remaining in the first stack is 0, and executing the remaining test steps by continuous looping further ensures that the occupied memory space is small, and further ensures that the execution efficiency of the test case is high.
[0056] Figure 4For the execution method of the test case using the present application Figure 3 Schematic diagram of the stack data changes during the execution of the test case. Figure 4 (1), (2), (3) and (7) represent the data change diagram of the first stack, and (4), (5) and (6) represent the data change diagram of the second stack.
[0057] Figure 5 For the execution method of the test case using the present application Figure 3 A schematic diagram of the test report generation process during the execution of the test cases in . Figure 5 As shown, each node under the first root node stores the first test report, and each node under the second root node stores the second test report; Figure 5 The first pointer node is used to point to the location of the first test report, and the second pointer node is used to point to the location of the second test report.
[0058] Specifically, if the above-mentioned test case also includes at least one secondary sub-test step corresponding to some of the above-mentioned sub-test steps, and the above-mentioned sub-test step corresponding to the above-mentioned secondary sub-test step is the target sub-test step, then the execution rules for this part of the above-mentioned secondary sub-test step are similar to the execution rules of the above-mentioned sub-test steps, and will not be repeated here.
[0059] In order to enable those skilled in the art to more clearly understand the technical solution of the present application, the implementation process of the test case execution method of the present application will be described in detail below in combination with specific embodiments.
[0060] The present embodiment relates to a specific method for executing a test case, wherein the test case includes a plurality of test steps arranged in sequence and at least one sub-test step corresponding to part of the test steps, wherein the test step corresponding to the sub-test step is a target test step, and the test sequence of the sub-test step is after the test of the corresponding target test step, such as Figure 6 As shown, the following steps are included:
[0061] Step S1: Store multiple test steps in reverse order into an initial stack to obtain a first stack; obtain a first pointer node and a first root node of a target linked list, the target linked list is used to store a first test report; generate a pointer to the target linked list; point the first pointer node to the first root node, and point the pointer of the target linked list to the first pointer node to generate a first trigger signal;
[0062] Step S2: in response to the first trigger signal, calling the test execution module to execute the test step corresponding to the pointing rule of the first pointer node, so as to generate a first test report in the target linked list, the first pointer node is used to point to the test step corresponding to the top of the first stack, and the test execution module is used to execute the test case;
[0063] Step S3: Determine whether the test step corresponding to the top of the first stack is the target test step;
[0064] Step S4: when the test step corresponding to the top of the first stack is the target test step, the sub-test steps corresponding to the target test step are stored in the first stack in reverse order to obtain a second stack; the second pointer node and the second root node of the target linked list are obtained, the target linked list is used to store the second test report, and the second root node is the root node of the target linked list except the first root node; the second pointer node is pointed to the second root node, and the pointer of the target linked list is pointed to the second pointer node to generate a second trigger signal;
[0065] Step S5: in response to the second trigger signal, calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node, so as to generate a second test report in the target linked list, wherein the second pointer node is used to point to the sub-test step corresponding to the top of the second stack;
[0066] Step S6: Generate a final test report of the test case according to the first test report and the second test report.
[0067] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0068] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium includes a stored program, wherein when the program is run, a method for executing the test case is controlled to execute a device where the computer-readable storage medium is located.
[0069] Specifically, the execution method of the test case includes:
[0070] Step S201, a first storage step, storing the plurality of the above test steps in reverse order into an initial stack to obtain a first stack;
[0071] Specifically, the test step at the top of the initial stack is the test step at the last position in the sorting, and the test step at the bottom of the initial stack is the test step at the first position in the sorting.
[0072] Step S202, a first response step, in response to a first trigger signal, calling a test execution module to execute the test step corresponding to the pointing rule of the first pointer node to obtain a first test report, wherein the first pointer node is used to point to the test step corresponding to the top of the first stack, and the test execution module is used to execute the test case;
[0073] Step S203, a first determination step, determining whether the test step corresponding to the top of the first stack is the target test step;
[0074] Step S204, a second storage step, in which, when the test step corresponding to the top of the first stack is the target test step, the sub-test steps corresponding to the target test step are stored in the first stack in reverse order to obtain a second stack;
[0075] Step S205, a second response step, in response to a second trigger signal, calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain a second test report, wherein the second pointer node is used to point to the sub-test step corresponding to the top of the second stack;
[0076] Step S206, a generating step, generates a final test report of the test case according to the first test report and the second test report.
[0077] Optionally, before the above-mentioned first response step, the above-mentioned method also includes: obtaining the above-mentioned first pointer node and the first root node of the target linked list, the above-mentioned target linked list is used to store the above-mentioned first test report; generating a pointer to the above-mentioned target linked list; pointing the above-mentioned first pointer node to the above-mentioned first root node, and pointing the pointer of the above-mentioned target linked list to the above-mentioned first pointer node to generate the above-mentioned first trigger signal, calling the test execution module to execute the above-mentioned test steps corresponding to the pointing rule of the first pointer node, and obtaining the first test report, including: calling the above-mentioned test execution module to execute the above-mentioned test steps corresponding to the pointing rule of the above-mentioned first pointer node to generate the above-mentioned first test report in the above-mentioned target linked list.
[0078] Optionally, after the above-mentioned second storage step and before the above-mentioned second response step, the above-mentioned method also includes: obtaining the above-mentioned second pointer node and the second root node of the above-mentioned target linked list, the above-mentioned target linked list is used to store the above-mentioned second test report, and the above-mentioned second root node is the root node of the above-mentioned target linked list except the above-mentioned first root node; pointing the above-mentioned second pointer node to the above-mentioned second root node, and pointing the pointer of the above-mentioned target linked list to the above-mentioned second pointer node to generate the above-mentioned second trigger signal, calling the above-mentioned test execution module to execute the above-mentioned sub-test step corresponding to the pointing rule of the second pointer node, and obtaining the second test report, including: calling the above-mentioned test execution module to execute the above-mentioned sub-test step corresponding to the pointing rule of the above-mentioned second pointer node to generate the above-mentioned second test report in the above-mentioned target linked list.
[0079] Optionally, the test execution module is called to execute the test steps corresponding to the pointing rule of the first pointer node to generate the first test report in the target linked list, including: calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to obtain the first test report; storing the first test report to the position corresponding to the node after the node pointed to by the first pointer node in the target linked list.
[0080] Optionally, the test execution module is called to execute the sub-test steps corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list, including: calling the test execution module to execute the sub-test steps corresponding to the pointing rule of the second pointer node to obtain the second test report; storing the second test report to the position corresponding to the node after the node pointed to by the second pointer node in the target linked list.
[0081] Optionally, after the second response step and before the generation step, the method further includes: a second determination step, determining whether the number of the sub-test steps remaining in the second stack is 0; and a first loop step, in a case where the number of the sub-test steps remaining in the second stack is not 0, looping the second response step and the second determination step until the number of the sub-test steps remaining in the second stack is 0.
[0082] Optionally, before the above-mentioned generating step, the above-mentioned method also includes: a third determining step, determining whether the number of the above-mentioned test steps remaining in the above-mentioned first stack is 0; a pointing step, when the number of the above-mentioned sub-test steps remaining in the above-mentioned second stack is 0, pointing the pointer of the above-mentioned target linked list to the above-mentioned first pointer node to generate the above-mentioned first trigger signal; a second looping step, when the number of the above-mentioned test steps remaining in the above-mentioned first stack is not 0, looping the above-mentioned pointing step and the above-mentioned first responding step until the number of the above-mentioned test steps remaining in the above-mentioned first stack is 0.
[0083] The present application also provides a computer program product, including computer instructions, which, when executed by a processor, implement at least the following method steps: step S201, a first storage step, storing multiple test steps in reverse order into an initial stack to obtain a first stack; step S202, a first response step, in response to a first trigger signal, calling a test execution module to execute the test steps corresponding to the pointing rule of a first pointer node to obtain a first test report, wherein the first pointer node is used to point to the test steps corresponding to the top of the first stack, and the test execution module is used to execute the test case; step S203, a first determination step, determining whether the test step corresponding to the top of the first stack is No is the target test step; step S204, a second storage step, in the case that the test step corresponding to the top of the first stack is the target test step, the sub-test step corresponding to the target test step is stored in the first stack in reverse order to obtain a second stack; step S205, a second response step, in response to a second trigger signal, calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain a second test report, and the second pointer node is used to point to the sub-test step corresponding to the top of the second stack; step S206, a generation step, generating a final test report for the test case according to the first test report and the second test report.
[0084] Optionally, before the above-mentioned first response step, the above-mentioned method also includes: obtaining the above-mentioned first pointer node and the first root node of the target linked list, the above-mentioned target linked list is used to store the above-mentioned first test report; generating a pointer to the above-mentioned target linked list; pointing the above-mentioned first pointer node to the above-mentioned first root node, and pointing the pointer of the above-mentioned target linked list to the above-mentioned first pointer node to generate the above-mentioned first trigger signal, calling the test execution module to execute the above-mentioned test steps corresponding to the pointing rule of the first pointer node, and obtaining the first test report, including: calling the above-mentioned test execution module to execute the above-mentioned test steps corresponding to the pointing rule of the above-mentioned first pointer node to generate the above-mentioned first test report in the above-mentioned target linked list.
[0085] Optionally, after the above-mentioned second storage step and before the above-mentioned second response step, the above-mentioned method also includes: obtaining the above-mentioned second pointer node and the second root node of the above-mentioned target linked list, the above-mentioned target linked list is used to store the above-mentioned second test report, and the above-mentioned second root node is the root node of the above-mentioned target linked list except the above-mentioned first root node; pointing the above-mentioned second pointer node to the above-mentioned second root node, and pointing the pointer of the above-mentioned target linked list to the above-mentioned second pointer node to generate the above-mentioned second trigger signal, calling the above-mentioned test execution module to execute the above-mentioned sub-test step corresponding to the pointing rule of the second pointer node, and obtaining the second test report, including: calling the above-mentioned test execution module to execute the above-mentioned sub-test step corresponding to the pointing rule of the above-mentioned second pointer node to generate the above-mentioned second test report in the above-mentioned target linked list.
[0086] Optionally, the test execution module is called to execute the test steps corresponding to the pointing rule of the first pointer node to generate the first test report in the target linked list, including: calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to obtain the first test report; storing the first test report to the position corresponding to the node after the node pointed to by the first pointer node in the target linked list.
[0087] Optionally, the test execution module is called to execute the sub-test steps corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list, including: calling the test execution module to execute the sub-test steps corresponding to the pointing rule of the second pointer node to obtain the second test report; storing the second test report to the position corresponding to the node after the node pointed to by the second pointer node in the target linked list.
[0088] Optionally, after the second response step and before the generation step, the method further includes: a second determination step, determining whether the number of the sub-test steps remaining in the second stack is 0; and a first loop step, in a case where the number of the sub-test steps remaining in the second stack is not 0, looping the second response step and the second determination step until the number of the sub-test steps remaining in the second stack is 0.
[0089] Optionally, before the above-mentioned generating step, the above-mentioned method also includes: a third determining step, determining whether the number of the above-mentioned test steps remaining in the above-mentioned first stack is 0; a pointing step, when the number of the above-mentioned sub-test steps remaining in the above-mentioned second stack is 0, pointing the pointer of the above-mentioned target linked list to the above-mentioned first pointer node to generate the above-mentioned first trigger signal; a second looping step, when the number of the above-mentioned test steps remaining in the above-mentioned first stack is not 0, looping the above-mentioned pointing step and the above-mentioned first responding step until the number of the above-mentioned test steps remaining in the above-mentioned first stack is 0.
[0090] An embodiment of the present application also provides an electronic device, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an execution method for executing any one of the test cases.
[0091] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0092] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0093] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0094] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0095] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0096] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0097] The memory may include non-permanent memory in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0098] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0099] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0100] From the above description, it can be seen that the above embodiments of the present application achieve the following technical effects:
[0101] In the test case execution method of the present application, first, multiple test steps are stored in an initial stack to obtain a first stack, and then in response to a first trigger signal, the test execution module is called to execute the test step corresponding to the pointing rule of the first pointer node to obtain a first test report, wherein the first pointer node is used to point to the test step corresponding to the top of the first stack, and then determine whether the test step corresponding to the top of the first stack corresponds to a sub-test step (that is, whether it is a target test step), and when it is a target test step, the sub-test step corresponding to the target test step is stored in the first stack in reverse order to obtain a second stack, and then in response to a second trigger signal, the test execution module is called to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain a second test report, and the second pointer node is used to point to the sub-test step corresponding to the top of the second stack, and finally, according to the first test report and the second test report, a final test report of the test case is generated. Compared with the prior art that uses recursive calls to execute test cases, which generates large memory consumption and leads to low execution efficiency, the present application stores multiple test steps in an initial stack in reverse order to obtain a first stack, and executes the test step corresponding to the top of the first stack to obtain a first test report. When there is a corresponding sub-test step for the test step corresponding to the top of the first stack, the corresponding sub-test step is stored in the first stack in reverse order to obtain a second stack, and the sub-test step corresponding to the top of the second stack is executed to obtain a second test report. That is, the hierarchical execution of the test case tree is realized by using a custom stack structure, which avoids recursive calls of the test case execution method, thereby avoiding the problem of excessive memory usage, and further ensuring high execution efficiency of the test cases.
[0102] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for executing a test case, characterized in that: The test case includes a plurality of test steps arranged in sequence and at least one sub-test step corresponding to part of the test steps, the test step corresponding to the sub-test step is a target test step, and the test sequence of the sub-test step is after the test of the corresponding target test step, and the method includes: A first storage step, storing the plurality of test steps in reverse order into an initial stack to obtain a first stack; A first response step, in response to a first trigger signal, calling a test execution module to execute the test step corresponding to the pointing rule of the first pointer node to obtain a first test report, wherein the first pointer node is used to point to the test step corresponding to the top of the first stack, and the test execution module is used to execute the test case; A first determination step is to determine whether the test step corresponding to the top of the first stack is the target test step; A second storage step, when the test step corresponding to the top of the first stack is the target test step, storing the sub-test steps corresponding to the target test step in the first stack in reverse order to obtain a second stack; A second response step, in response to a second trigger signal, calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain a second test report, wherein the second pointer node is used to point to the sub-test step corresponding to the top of the second stack; A generating step, generating a final test report of the test case according to the first test report and the second test report.
2. The test case execution method according to claim 1, characterized in that: Before the first responding step, the method further comprises: Obtain the first pointer node and a first root node of a target linked list, where the target linked list is used to store the first test report; Generate a pointer to the target linked list; Pointing the first pointer node to the first root node, and pointing the pointer of the target linked list to the first pointer node, to generate the first trigger signal, Calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to obtain the first test report includes: calling the test execution module to execute the test steps corresponding to the pointing rule of the first pointer node to generate the first test report in the target linked list.
3. The test case execution method according to claim 2, characterized in that: After the second storing step and before the second responding step, the method further includes: Acquire the second pointer node and a second root node of the target linked list, where the target linked list is used to store the second test report, and the second root node is a root node in the target linked list except the first root node; The second pointer node points to the second root node, and the pointer of the target linked list points to the second pointer node, so as to generate the second trigger signal. Calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain the second test report includes: calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list.
4. The test case execution method according to claim 2, characterized in that: Calling the test execution module to execute the test step corresponding to the pointing rule of the first pointer node to generate the first test report in the target linked list includes: Calling the test execution module to execute the test step corresponding to the pointing rule of the first pointer node to obtain the first test report; The first test report is stored in a position corresponding to a node after the node pointed to by the first pointer node in the target linked list.
5. The test case execution method according to claim 3, characterized in that: Calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to generate the second test report in the target linked list includes: Calling the test execution module to execute the sub-test step corresponding to the pointing rule of the second pointer node to obtain the second test report; The second test report is stored in a position corresponding to a node after the node pointed to by the second pointer node in the target linked list.
6. The test case execution method according to claim 3, characterized in that: After the second responding step and before the generating step, the method further includes: a second determination step of determining whether the number of the sub-test steps remaining in the second stack is 0; The first loop step is to loop the second response step and the second determination step when the number of the sub-test steps remaining in the second stack is not zero, until the number of the sub-test steps remaining in the second stack is zero.
7. The test case execution method according to claim 6, characterized in that: Before the generating step, the method further comprises: A third determination step, determining whether the number of the test steps remaining in the first stack is 0; Pointing step, when the number of the sub-test steps remaining in the second stack is 0, pointing the pointer of the target linked list to the first pointer node to generate the first trigger signal; The second loop step is to loop the pointing step and the first responding step when the number of the test steps remaining in the first stack is not zero, until the number of the test steps remaining in the first stack is zero.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored program, wherein when the program is executed, the device where the computer-readable storage medium is located is controlled to execute the test case execution method according to any one of claims 1 to 7.
9. A computer program product comprising computer instructions, characterized in that When the computer instructions are executed by a processor, the method for executing the test case described in any one of claims 1 to 7 is implemented.
10. An electronic device, characterized in that: include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the one or more programs include an execution method for executing the test case described in any one of claims 1 to 7.
