Test case generation method and device, electronic equipment and storage medium
By quantifying the importance and constraints of the system's functional points, establishing a graph structure, and using reinforcement learning algorithms to generate test cases, it solves the problem that testers need to invest a lot of time in large systems to learn and analyze functional points, and improves test case generation Efficiency and quality.
Patent Information
- Application Number
- CN202411436221.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-18
AI Technical Summary
In large systems, testers need to invest a lot of time and effort to learn and analyze unfamiliar functional points, resulting in inefficient test case generation.
By quantifying the importance of system functional points and digitizing constraints, a graph structure is established, and the graph structure is maintained when system functional points change. Based on reinforcement learning algorithms, we explore paths and generate test cases that meet the conditions.
It reduces the learning cost of testers for related parts of the system and improves the writing efficiency and quality of test cases.
Smart Images

Figure CN119473833A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of test case generation, and in particular to a test case generation method, device, electronic device, and storage medium. Background Art
[0002] The generation of test cases often requires a lot of analysis and understanding of the requirements documents. In large systems, testers have different focuses on their understanding and analysis of the entire system. When faced with unfamiliar functional points that will affect the functional parts that they need to test, they need to invest a lot of time and energy to learn and analyze the relevant functional logic. Summary of the invention
[0003] The embodiments of the present application provide a test case generation method, device, electronic device, and storage medium to reduce the learning cost of testers on the functions and business logic of related parts in the system and improve the efficiency of test case writing.
[0004] The present application embodiment adopts the following technical solutions:
[0005] In a first aspect, an embodiment of the present application provides a test generation method, wherein the method comprises:
[0006] Quantify the importance of system function points and digitize the constraints between system function points;
[0007] According to the result of the quantification of the importance and the result of the digitization of the constraint condition, a graph structure is established, wherein the graph structure includes node information and edge information, wherein the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function nodes;
[0008] When a system function point changes, maintaining the node information and the edge information in the graph structure;
[0009] Explore paths based on reinforcement learning algorithms and output paths that meet the conditions;
[0010] Generate corresponding test cases according to the constraints between nodes in the found path that meets the conditions.
[0011] In some embodiments, when a system function point changes, maintaining the node information and the edge information in the graph structure includes:
[0012] When the system function point changes, any one or more node information and edge information maintenance operations of adding, deleting, and changing are performed on the basis of the graph structure;
[0013] The method of exploring a path based on a reinforcement learning algorithm and outputting a path that meets the conditions found includes:
[0014] The intelligent agent explores the nodes in the graph structure according to requirements through reinforcement learning. When the fluctuation range of the cumulative reward value obtained through exploration and learning is less than the specified degree, the training is terminated and the path found that meets the conditions is output.
[0015] In some embodiments, the step of exploring a path based on a reinforcement learning algorithm and outputting a path that satisfies a condition includes:
[0016] According to prior knowledge, the importance of the quantified function points is converted into a reward value (0,1], and the reward value of each node is set to be collected once;
[0017] The penalty value of each step in the path is set according to the specific situation of the system to be tested. Each additional function point in the path will reduce the cumulative reward value by the corresponding penalty value.
[0018] The end point of the exploration path is set according to the input destination node, and the penalty value when the destination node is given is not used.
[0019] In some embodiments, the method further comprises:
[0020] The agent collects the reward values of nodes through trial and error, looking for a path that results in a higher cumulative reward value.
[0021] In some embodiments, the method further comprises:
[0022] Set the training convergence condition, that is, the fluctuation of the cumulative reward value within x steps is less than n, and through continuous training, the agent can find a path that meets the requirements.
[0023] In some embodiments, quantifying the importance of system function points and digitizing the constraints between system function points includes:
[0024] Quantify the importance of function points according to the specific system (0,1]);
[0025] Assign values to the function points in turn according to their importance.
[0026] In some embodiments, the quantifying the importance of system function points and digitizing the constraints between system function points further includes:
[0027] Saving the importance assignment in the node corresponding to the system function point;
[0028] The necessary conditions for a node to reach the function point are stored in the node corresponding to the system function point.
[0029] In a second aspect, an embodiment of the present application further provides a test generation device, wherein the device comprises:
[0030] Initialization module, used to quantify the importance of system function points and digitize the constraints between system function points;
[0031] A graph structure module, used to establish a graph structure according to the quantified result of the importance and the digitized result of the constraint condition, wherein the graph structure includes node information and edge information, wherein the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function nodes;
[0032] A maintenance module, used for maintaining the node information and the edge information in the graph structure when a system function point changes;
[0033] A reinforcement learning module is used to explore paths based on a reinforcement learning algorithm and output the paths that meet the conditions.
[0034] The generation module is used to generate corresponding test cases according to the constraints between nodes in the found path that meets the conditions.
[0035] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: a processor; and a memory arranged to store computer executable instructions, wherein the executable instructions, when executed, cause the processor to perform the above method.
[0036] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, which stores one or more programs. When the one or more programs are executed by an electronic device including multiple application programs, the electronic device executes the above method.
[0037] At least one of the above technical solutions adopted in the embodiment of the present application can achieve the following beneficial effects: by quantifying the importance of system function points and digitizing the constraints between system function points, and then establishing a graph structure according to the results of the quantification of the importance and the digitization of the constraints, the graph structure includes node information and edge information, the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function points. In the case of changes in the system function points, the node information and the edge information in the graph structure are maintained, and the path is further explored based on the reinforcement learning algorithm and the path that meets the conditions is output, and the corresponding test case is generated according to the constraints between the nodes in the path that meets the conditions. The above method, by manually maintaining the function points of the system to be tested, the function points of the system to be tested are digitally stored as a graph structure; and then by adding, deleting, and modifying the nodes in the graph structure, the functional logic and structure of the system are maintained more efficiently, thereby reducing the learning cost of the test personnel for the functions and business logic of the related parts of the system, and improving the efficiency of writing test cases. In addition, the above method introduces reinforcement learning to explore the paths in the graph structure and generate test cases that meet the conditions, which can correspond to the coverage of important function points, reduce the operation steps and other conditions, and improve the quality of test cases. Accurately store function points and generate the required start-point to end-point test cases to improve the efficiency of test case generation. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0039] Figure 1 A flow chart of a test generation method in an embodiment of the present application;
[0040] Figure 2 This is a schematic diagram of the overall workflow of the test generation method in the embodiment of the present application;
[0041] Figure 3 A schematic diagram of a workflow in which an intelligent agent automatically explores and finds a path that meets the requirements in a test generation method in an embodiment of the present application;
[0042] Figure 4 This is a schematic diagram of the structure of a test generation device in an embodiment of the present application;
[0043] Figure 5 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0044] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. 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 making creative work are within the scope of protection of the present application.
[0045] The inventors found during their research that the deficiencies in the related art are:
[0046] 1) Test cases are written manually, and the quality of the test cases can only be guaranteed by writing specifications and work experience.
[0047] 2) When the system to be tested is relatively large, each tester will have division of labor and focus on the functional parts. For the related parts that they are not familiar with, they still need to invest a lot of time and energy to communicate, learn, and analyze in order to complete the writing of test cases, and they cannot share the error-prone and omission-prone points encountered in the related parts in a timely manner.
[0048] 3) When facing incremental development or agile development, system functions are changed or added, and new test cases need to be written based on existing test cases. Manually referring to existing test cases is time-consuming and labor-intensive. When the project cycle is tight, the dependence between the system to be tested and the tester is also high.
[0049] The test generation method in the embodiment of the present application quantifies the quality of the test case by the importance and coverage of the function points, thereby improving the quality of the generated test cases. The system structure is maintained by adding and changing function nodes, and the existing function structure can be automatically explored to generate test cases, providing references for testers, greatly improving the efficiency of test case writing and reducing the degree of dependence of projects on people.
[0050] In addition, the test generation method in the embodiment of the present application also provides testers with distributed maintenance of focused functional points, and automatically generates test cases corresponding to the starting point to the end point through the exploration of the entire functional system, thereby reducing the learning cost of testers and improving work efficiency.
[0051] The technical solutions provided by various embodiments of the present application are described in detail below in conjunction with the accompanying drawings.
[0052] The present application embodiment provides a test generation method, such as Figure 1 As shown, a flow chart of a test generation method in an embodiment of the present application is provided, and the method at least includes the following steps S110 to S150:
[0053] Step S110, quantifying the importance of system function points and digitizing the constraints between system function points.
[0054] "System function points" mainly refer to the function points with different functions in the system to be tested. By quantifying the importance of system function points, the system function points can be ranked according to different importance levels.
[0055] The constraints between system function points mainly refer to the degree of close or loose association between system function points, or the degree of mutual influence between system function points, or the degree of association between previous and next executions of system function points.
[0056] Step S120, establishing a graph structure according to the result of the quantification of the importance and the digitization of the constraint conditions, wherein the graph structure includes node information and edge information, wherein the node information is used to characterize the importance of the functional nodes, and the edge information is used to characterize the constraint relationship between the functional points.
[0057] According to the results of quantifying the importance and the results of digitizing the constraints, a graph G(V,E) corresponding to the system to be tested is constructed. It can be understood that a graph, as a data structure, consists of a finite non-empty set V(G) of vertices and a set E(G) of edges between vertices, usually expressed as: G = (V, E), where G represents the entire graph, V is the set of vertices in the graph G, and E is the set of edges in the graph G.
[0058] It can be understood that the constraints between function points include but are not limited to necessary conditions and sufficient conditions for triggering the function points, and are particularly represented by edges between nodes and information of nodes in the embodiments of the present application.
[0059] Step S130: When a system function point changes, the node information and the edge information in the graph structure are maintained.
[0060] When a system function point is added or changed, the node information and the edge information in the graph structure are maintained, the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function points.
[0061] Step S140, exploring paths based on a reinforcement learning algorithm and outputting the found paths that meet the conditions.
[0062] Based on the premise of quantifying the importance of functional points to requirements, the cumulative reward values are collected through reinforcement learning exploration paths to find more qualified paths, thereby generating corresponding test cases, which can improve the efficiency of test case writing and improve the quality of test cases.
[0063] It should be noted that reinforcement learning method refers to a method of obtaining better strategies through continuous trial and error with the goal of obtaining greater cumulative rewards.
[0064] Step S150, generating corresponding test cases according to the constraints between the nodes in the found path that meets the conditions.
[0065] The intelligent agent automatically explores the nodes in the graph structure according to requirements through reinforcement learning. After exploration and learning, the training ends when the fluctuation range of the cumulative reward value is less than the specified degree, and the found path that meets the conditions is output. Finally, the corresponding test cases are generated according to the constraints between the nodes in the path.
[0066] It can be understood that the reward value refers to the reaction of the interaction between the agent and the environment in reinforcement learning, which is used to reward or motivate the agent to learn and train positively (positive reward value) or negatively (negative reward value).
[0067] In addition, the cumulative reward value refers to the sum of the reward values after a series of actions in which the intelligent agent continuously collects responses to interactions with the environment in reinforcement learning, and the quality of the current action is measured by the cumulative reward value.
[0068] Through the above method, the importance of system function points is quantified and the constraints between system function points are digitized; and according to the results of the quantification of the importance and the digitization of the constraints, a graph structure is established. Through heuristic exploration of the graph structure, test cases that meet the requirements are searched, test cases are automatically generated, and the efficiency of test case generation is improved. In addition, the nodes in the graph structure storing the system function points can be dynamically added, deleted, and modified so that the system functions can be added, deleted, and changed in the graph structure.
[0069] Through the above method, when the system function points are changed, the node information and the edge information in the graph structure are maintained. In this way, the business logic and function points in the requirements can be digitally stored as a graph structure, and testers who focus on different functional points can maintain the parts they are familiar with in a distributed manner, and efficiently maintain the logic of the entire system. This improves the management and maintenance efficiency of function points and business logic, while reducing the learning cost of new project personnel.
[0070] Through the above method, the path is explored based on the reinforcement learning algorithm and the path that meets the conditions is output; and the corresponding test cases are generated according to the constraints between the nodes in the path that meets the conditions. By collecting the importance of function points and whether they are traversed or not, the coverage of important function points is maximized and unnecessary steps are reduced to provide high-quality test cases. Testers can complete the writing of test cases more efficiently on this basis, thereby improving the quality of test cases.
[0071] In one embodiment of the present application, maintaining the node information and the edge information in the graph structure when a system function point changes includes: performing any one or more maintenance operations of adding, deleting, and changing the node information and edge information on the basis of the graph structure when a system function point changes; exploring paths based on a reinforcement learning algorithm and outputting the found paths that meet the conditions includes: the intelligent agent explores the nodes in the graph structure according to requirements through reinforcement learning, and ends the training when the fluctuation range of the cumulative reward value obtained through exploration and learning is less than a specified degree, and outputs the found paths that meet the conditions.
[0072] like Figure 2 As shown in the figure, when the system function point changes, the node information and edge information are added, deleted, or changed based on the original graph structure. The agent automatically explores the nodes in the graph structure according to the requirements through reinforcement learning. After exploration and learning, when the fluctuation range of the cumulative reward value is less than the specified degree, the training ends and the path that meets the conditions is output. In other words, the system function points with closer relationships are found through reinforcement learning.
[0073] In one embodiment of the present application, the method of exploring paths based on a reinforcement learning algorithm and outputting the found paths that meet the conditions includes: converting the importance of quantified function points into a reward value (0,1] according to prior knowledge, and setting the reward value of each node to be collected once; setting the penalty value of each step in the path according to the specific situation of the system to be tested, so that each additional function point in the path will reduce the cumulative reward value by a corresponding penalty value; setting the end point of the exploration path according to the input destination node, and not using the penalty value when the destination node is given.
[0074] like Figure 3 As shown, set the reporting value and collection rules for each node. Set the path step penalty value.
[0075] In case 1, based on experience and prior knowledge such as probability theory and random processes, the quantified importance of function points is converted into a reward value (0, 1], and the reward value of each node can only be collected once, so as to ensure that the path will not fall into an infinite loop.
[0076] like Figure 3 As shown, maintain node information and edge information. Enter the starting node and destination node, and set the conditions for training convergence.
[0077] Case 2, please continue to refer to Figure 3, according to the specific situation of the system to be tested, the penalty value of each step in the path is set. Each additional function point in the path will reduce the cumulative reward value by the corresponding penalty value of each step, so that the intelligent agent reduces redundant paths when exploring the path. For example, when there is a password verification error in the system, the function point of re-entering the password to log in is repeated several times, which is a redundant path. The algorithm uses the step penalty value to avoid excessive repetition of this situation.
[0078] like Figure 3 As shown, the training learns to collect higher reward values, determines whether the training is completed, and if so, outputs the most qualified path explored.
[0079] In case three, the penalty value when the end point of the exploration path is not the given destination node is set according to the input destination node, so that the agent can explore towards the given destination as much as possible.
[0080] In one embodiment of the present application, the method further includes: the agent collects the reward values of the nodes by trial and error to find a path that makes the cumulative reward value higher.
[0081] The agent collects the reward values of nodes by trial and error, and looks for a path that makes the cumulative reward value higher. For example, the agent learns how to explore the high-reward function points in case 1 during training, reduces the collection penalty value in case 2 by learning to reduce redundant paths, and learns to find the correct end point to avoid the high penalty value in case 3.
[0082] The above-mentioned penalty value processing method is only an example and is not used to limit the protection scope of the embodiments of the present application.
[0083] In one embodiment of the present application, the method further includes: setting a training convergence condition, that is, the fluctuation of the cumulative reward value within x steps is less than n, and through continuous training, the intelligent agent can find a path that meets the requirements.
[0084] like Figure 3 As shown in the figure, the training convergence condition is set, that is, the fluctuation of the cumulative reward value within x steps is less than n (for example, the penalty value of each step in the path is set according to the specific situation of the system to be tested, such as -0.4, and the penalty value when the end point of the exploration path is not the given destination node is set according to the input destination node, such as -20, and the cumulative reward value within 20 steps is less than the fluctuation is less than 1). Through continuous training, the intelligent agent can find a path that meets the requirements with a high probability.
[0085] In one embodiment of the present application, the quantification of the importance of system function points and the digitization of the constraints between system function points include: quantifying the importance of function points according to the specific system (0,1]; and assigning values to the function points in sequence according to the importance of different important function points.
[0086] like Figure 2 As shown, according to the specific system, the importance of the function points is quantified (0,1], and the importance of the most important function point is assigned a value of 1, the second most important function point is assigned a value of 0.9, and so on. Specifically, for example, in the subject of life payment, the first thing to do is to ensure the logical correctness of querying arrears and completing deductions. The most important function points such as querying arrears and completing deductions are assigned a value of 1, while the recommended payment function is only assigned a value of 0.5, and so on. This is not specifically limited in the embodiments of the present application.
[0087] In one embodiment of the present application, the quantification of the importance of system function points and the digitization of the constraints between system function points also include: saving the importance assignment in the node corresponding to the system function point; and saving the necessary conditions for the node to reach the function point in the node corresponding to the system function point.
[0088] like Figure 2 As shown in FIG, the node corresponding to the function point stores the importance value and the necessary conditions for reaching the function point. For example, by judging whether two nodes are connected, and using edges to record the degree of relationship between the two nodes.
[0089] Specifically, the test case generation of the functional points in the system includes: the function of querying the account balance must have the conditions such as the previous input of the account and the verification password, and the nodes corresponding to the input account and the verification password are placed in the necessary conditions of the node for querying the account balance.
[0090] The present application embodiment also provides a test case generating device 400, such as Figure 4 As shown, a schematic diagram of the structure of a test case generating device in an embodiment of the present application is provided, wherein the test case generating device 400 at least includes: an initialization module 410, a graph structure module 420, a maintenance module 430, a reinforcement learning module 440 and a generation module 450, wherein:
[0091] In one embodiment of the present application, the initialization module 410 is specifically used to: quantify the importance of system function points and digitize the constraints between system function points.
[0092] "System function points" mainly refer to the function points with different functions in the system to be tested. By quantifying the importance of system function points, the system function points can be ranked according to different importance levels.
[0093] The constraints between system function points mainly refer to the degree of close or loose association between system function points, or the degree of mutual influence between system function points, or the degree of association between previous and next executions of system function points.
[0094] In one embodiment of the present application, the graph structure module 420 is specifically used to: establish a graph structure based on the results of the quantification of the importance and the digitization of the constraint conditions, the graph structure including node information and edge information, the node information is used to characterize the importance of the functional nodes, and the edge information is used to characterize the constraint relationship between the functional points.
[0095] According to the results of quantifying the importance and the results of digitizing the constraints, a graph G(V,E) corresponding to the system to be tested is constructed. It can be understood that a graph, as a data structure, consists of a finite non-empty set V(G) of vertices and a set E(G) of edges between vertices, usually expressed as: G = (V, E), where G represents the entire graph, V is the set of vertices in the graph G, and E is the set of edges in the graph G.
[0096] It can be understood that the constraints between function points include but are not limited to necessary conditions and sufficient conditions for triggering the function points, and are particularly represented by edges between nodes and information of nodes in the embodiments of the present application.
[0097] In one embodiment of the present application, the maintenance module 430 is specifically used to maintain the node information and the edge information in the graph structure when a system function point changes.
[0098] When a system function point is added or changed, the node information and the edge information in the graph structure are maintained, the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function points.
[0099] In one embodiment of the present application, the reinforcement learning module 440 is specifically used to: explore paths based on a reinforcement learning algorithm and output the found paths that meet the conditions.
[0100] Based on the premise of quantifying the importance of functional points to requirements, the cumulative reward values are collected through reinforcement learning exploration paths to find more qualified paths, thereby generating corresponding test cases, which can improve the efficiency of test case writing and improve the quality of test cases.
[0101] It should be noted that reinforcement learning method refers to a method of obtaining better strategies through continuous trial and error with the goal of obtaining greater cumulative rewards.
[0102] In one embodiment of the present application, the generating module 450 is specifically used to generate corresponding test cases according to the constraints between nodes in the found path that meets the conditions.
[0103] The intelligent agent automatically explores the nodes in the graph structure according to requirements through reinforcement learning. After exploration and learning, the training ends when the fluctuation range of the cumulative reward value is less than the specified degree, and the found path that meets the conditions is output. Finally, the corresponding test cases are generated according to the constraints between the nodes in the path.
[0104] It can be understood that the reward value refers to the reaction of the interaction between the agent and the environment in reinforcement learning, which is used to reward or motivate the agent to learn and train positively (positive reward value) or negatively (negative reward value).
[0105] In addition, the cumulative reward value refers to the sum of the reward values after a series of actions in which the intelligent agent continuously collects responses to interactions with the environment in reinforcement learning, and the quality of the current action is measured by the cumulative reward value.
[0106] In one embodiment of the present application, the maintenance module 430 is also used to
[0107] When the system function point changes, any one or more node information and edge information maintenance operations of adding, deleting, and changing are performed on the basis of the graph structure;
[0108] The reinforcement learning module 440 is also used to
[0109] The intelligent agent explores the nodes in the graph structure according to requirements through reinforcement learning. When the fluctuation range of the cumulative reward value obtained through exploration and learning is less than the specified degree, the training is terminated and the path found that meets the conditions is output.
[0110] In one embodiment of the present application, the reinforcement learning module 440 is also used to
[0111] According to prior knowledge, the importance of the quantified function points is converted into a reward value (0,1], and the reward value of each node is set to be collected once;
[0112] The penalty value of each step in the path is set according to the specific situation of the system to be tested. Each additional function point in the path will reduce the cumulative reward value by the corresponding penalty value.
[0113] The end point of the exploration path is set according to the input destination node, and the penalty value when the destination node is given is not used.
[0114] In one embodiment of the present application, it further includes: a first optimization module for
[0115] The agent collects the reward values of nodes through trial and error, looking for a path that results in a higher cumulative reward value.
[0116] In one embodiment of the present application, it further includes: a second optimization module for
[0117] Set the training convergence condition, that is, the fluctuation of the cumulative reward value within x steps is less than n, and through continuous training, the agent can find a path that meets the requirements.
[0118] In one embodiment of the present application, the second optimization module is also used to
[0119] Quantify the importance of function points according to the specific system (0,1]);
[0120] Assign values to the function points in turn according to their importance.
[0121] In one embodiment of the present application, the initialization module 410 is also used to
[0122] Saving the importance assignment in the node corresponding to the system function point;
[0123] The necessary conditions for a node to reach the function point are stored in the node corresponding to the system function point.
[0124] It can be understood that the above-mentioned test case generation device can implement each step of the test case generation method provided in the above-mentioned embodiment, and the relevant explanations about the test case generation method are applicable to the test case generation device and will not be repeated here.
[0125] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present application. Figure 5 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0126] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0127] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0128] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a test case generation device at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0129] Quantify the importance of system function points and digitize the constraints between system function points; establish a graph structure based on the results of the importance quantification and the results of the constraint digitization, the graph structure includes node information and edge information, the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function points;
[0130] When a system function point changes, maintaining the node information and the edge information in the graph structure;
[0131] Explore paths based on reinforcement learning algorithms and output paths that meet the conditions;
[0132] Generate corresponding test cases according to the constraints between nodes in the found path that meets the conditions.
[0133] The above application Figure 1The method performed by the test case generation device disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0134] The electronic device may also perform Figure 1 The method for executing the test case generation device in Figure 1 The functions of the illustrated embodiment will not be described in detail in the embodiments of the present application.
[0135] The present application also provides a computer-readable storage medium, which stores one or more programs, wherein the one or more programs include instructions, which, when executed by an electronic device including multiple application programs, enable the electronic device to execute Figure 1 The method executed by the test case generation device in the embodiment shown is specifically used to execute:
[0136] Quantify the importance of system function points and digitize the constraints between system function points;
[0137] According to the result of the quantification of the importance and the result of the digitization of the constraint condition, a graph structure is established, wherein the graph structure includes node information and edge information, wherein the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function nodes;
[0138] When a system function point changes, maintaining the node information and the edge information in the graph structure;
[0139] Explore paths based on reinforcement learning algorithms and output paths that meet the conditions;
[0140] Generate corresponding test cases according to the constraints between nodes in the found path that meets the conditions.
[0141] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0142] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks 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 produce 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.
[0143] 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.
[0144] 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.
[0145] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0146] The memory may include non-permanent storage 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.
[0147] 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 magnetic 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.
[0148] 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.
[0149] 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 on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program code.
[0150] The above is only an 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 changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A test case generation method, wherein: The method comprises: Quantify the importance of system function points and digitize the constraints between system function points; According to the result of the quantification of the importance and the result of the digitization of the constraint condition, a graph structure is established, wherein the graph structure includes node information and edge information, wherein the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function nodes; When a system function point changes, maintaining the node information and the edge information in the graph structure; Explore paths based on reinforcement learning algorithms and output paths that meet the conditions; Generate corresponding test cases according to the constraints between nodes in the found path that meets the conditions.
2. The method of claim 1, wherein: When a system function point changes, maintaining the node information and the edge information in the graph structure includes: When the system function point changes, any one or more node information and edge information maintenance operations of adding, deleting, and changing are performed on the basis of the graph structure; The method of exploring a path based on a reinforcement learning algorithm and outputting a path that meets the conditions found includes: The intelligent agent explores the nodes in the graph structure according to requirements through reinforcement learning. When the fluctuation range of the cumulative reward value obtained through exploration and learning is less than the specified degree, the training is terminated and the path found that meets the conditions is output.
3. The method of claim 1, wherein: The method of exploring a path based on a reinforcement learning algorithm and outputting a path that meets the conditions found includes: According to prior knowledge, the importance of the quantified function points is converted into a reward value (0,1], and the reward value of each node is set to be collected once; The penalty value of each step in the path is set according to the specific situation of the system to be tested. Each additional function point in the path will reduce the cumulative reward value by the corresponding penalty value. The end point of the exploration path is set according to the input destination node, and the penalty value when the destination node is given is not used.
4. The method of claim 3, wherein: The method further comprises: The agent collects the reward values of nodes through trial and error, looking for a path that results in a higher cumulative reward value.
5. The method of claim 3, wherein: The method further comprises: Set the training convergence condition, that is, the fluctuation of the cumulative reward value within x steps is less than n, and through continuous training, the agent can find a path that meets the requirements.
6. The method of claim 1, wherein: The quantification of the importance of system function points and the digitization of the constraints between system function points include: Quantify the importance of function points according to the specific system (0,1]); Assign values to the function points in turn according to their importance.
7. The method of claim 6, wherein: The quantification of the importance of the system function points and the digitization of the constraints between the system function points also include: Saving the importance assignment in the node corresponding to the system function point; The necessary conditions for a node to reach the function point are stored in the node corresponding to the system function point.
8. A test case generating device, wherein: The device comprises: Initialization module, used to quantify the importance of system function points and digitize the constraints between system function points; A graph structure module, used to establish a graph structure according to the quantified result of the importance and the digitized result of the constraint condition, wherein the graph structure includes node information and edge information, wherein the node information is used to characterize the importance of the function node, and the edge information is used to characterize the constraint relationship between the function nodes; A maintenance module, used for maintaining the node information and the edge information in the graph structure when a system function point changes; A reinforcement learning module is used to explore paths based on a reinforcement learning algorithm and output the paths that meet the conditions. The generation module is used to generate corresponding test cases according to the constraints between nodes in the found path that meets the conditions.
9. An electronic device, comprising: processor; as well as A memory arranged to store computer executable instructions, which when executed cause the processor to perform the method of any one of claims 1 to 7.
10. A computer-readable storage medium storing one or more programs, which, when executed by an electronic device including a plurality of application programs, causes the electronic device to execute any one of the methods of claims 1 to 7.