Test case generation method and device, electronic equipment and medium

The test correlation degree is judged through the control flow diagram, and the target condition group is selected to generate test cases, which solves the problem of low efficiency in the generation of test cases in the existing technology and improves the testing efficiency of large projects.

CN119248635APending Publication Date: 2025-01-03SHANDONG YUNHAI GUOCHUANG CLOUD COMPUTING EQUIP IND INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411170409.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

In the prior art, the efficiency of test case generation is low, especially in large projects. Due to the complex code logic, there are many coverage conditions that require verification, which leads to inefficient test case generation and the overall testing time for testing design is long.

Method used

By obtaining the control flow diagram corresponding to the coverage conditions of the design to be tested, determining the test correlation between each coverage conditions to be selected, selecting the selected condition group that meets the test requirements as the target group, and generating test cases based on the target group to avoid each Each coverage condition generates test cases separately.

Benefits of technology

This greatly reduces the test case generation time and overall test time, improves the test case generation efficiency, and realizes the generation of test case sequences that meet multiple coverage conditions at once.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119248635A_ABST
    Figure CN119248635A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a test case generation method and device, electronic equipment and a medium, and relates to the technical field of computers.The method comprises the steps that based on coverage conditions of to-be-tested design, control flow diagrams corresponding to the coverage conditions are obtained; for any one to-be-selected condition group in the plurality of to-be-selected condition groups, based on the control flow diagram corresponding to each to-be-selected coverage condition, determining a test association degree between the to-be-selected coverage conditions, and taking the test association degree as a test association degree corresponding to the to-be-selected condition group; the to-be-selected coverage conditions are coverage conditions included in the to-be-selected condition group, and the to-be-selected condition group comprises at least two coverage conditions; determining the to-be-selected condition group of which the corresponding test association degree meets the test requirement as a target group; and generating a test case based on the target group. And the test case generation efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and in particular, relates to a test case generation method, device, electronic device and medium. Background Art

[0002] With the development of computer technology, it is often necessary to test and verify the designed software, and test verification depends on test cases. The test cases need to be input into the design to be tested to verify whether the design to be tested meets certain design requirements.

[0003] For some large projects, due to the complex code logic, there are a large number of coverage conditions that need to be verified. Currently, test cases are often generated separately for each coverage condition and tested separately. This method will greatly reduce the efficiency of test case generation. Summary of the invention

[0004] The present application provides a test case generation method, device, electronic device and medium to solve the technical problem of low test case generation efficiency in related technologies.

[0005] In order to solve the above technical problems, this application is implemented as follows:

[0006] In a first aspect, the present application provides a test case generation method, the method comprising:

[0007] Based on the coverage conditions of the design to be tested, obtaining a control flow graph corresponding to each of the coverage conditions;

[0008] For any one of the multiple candidate condition groups, based on the control flow graph corresponding to each candidate coverage condition, determine the test association between the candidate coverage conditions as the test association corresponding to the candidate condition group; the candidate coverage condition is the coverage condition included in the candidate condition group, and the candidate condition group includes at least two of the coverage conditions;

[0009] Determine the candidate condition group whose corresponding test correlation degree meets the test requirements as the target group;

[0010] Test cases are generated based on the target group.

[0011] In a second aspect, the present application provides a test case generation device, the device comprising:

[0012] A first acquisition module is used to acquire a control flow graph corresponding to each coverage condition based on the coverage conditions of the design to be tested;

[0013] A first determination module is used to determine, for any one of the multiple candidate condition groups, the test association between the candidate coverage conditions based on the control flow graph corresponding to each candidate coverage condition, as the test association corresponding to the candidate condition group; the candidate coverage condition is the coverage condition included in the candidate condition group, and the candidate condition group includes at least two of the coverage conditions;

[0014] A second determination module is used to determine the candidate condition group whose corresponding test association degree meets the test requirement as the target group;

[0015] A generating module is used to generate test cases based on the target group.

[0016] In a third aspect, the present application provides an electronic device comprising: a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method of the first aspect when executing the program.

[0017] In a fourth aspect, the present application provides a readable storage medium, when the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute the method of the first aspect above.

[0018] In an embodiment of the present application, based on the coverage conditions of the design to be tested, a control flow graph corresponding to each of the coverage conditions is obtained; for any of the multiple condition groups to be selected, based on the control flow graph corresponding to each of the coverage conditions to be selected, the test correlation between the coverage conditions to be selected is determined as the test correlation corresponding to the condition group to be selected; the coverage conditions to be selected are the coverage conditions contained in the condition group to be selected, and the condition group to be selected contains at least two of the coverage conditions; the condition group to be selected whose corresponding test correlation meets the test requirements is determined as the target group; and a test case is generated based on the target group. In this way, the embodiment of the present application judges the test correlation between each coverage condition through a control flow graph, and then selects the condition group to be selected whose test correlation meets the test requirements as the target group, and generates a test case through the target group, so that there is no need to generate a separate test case for each coverage condition, and a test case sequence that meets multiple coverage conditions can be generated at one time, thereby greatly reducing the test case generation time, improving the test case generation efficiency, and greatly reducing the overall test time for the design to be tested. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related technologies, the following is a brief introduction to the drawings required for use in the embodiments or the related technical descriptions. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 It is a flowchart of the steps of a test case generation method provided by an embodiment of the present application;

[0021] Figure 2 It is a structural schematic diagram of a control flow graph provided in an embodiment of the present application;

[0022] Figure 3 It is a schematic diagram of the structure of a preset record set provided in an embodiment of the present application;

[0023] Figure 4 is a schematic diagram of the structure of another preset record set provided in an embodiment of the present application;

[0024] Figure 5 This is a flow chart of test case generation provided by an embodiment of the present application;

[0025] Figure 6 It is a structural diagram of a test case generation device provided in an embodiment of the present application;

[0026] Figure 7 It is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0027] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are 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 are within the scope of protection of this application.

[0028] Figure 1 is a flow chart of the steps of a test case generation method provided by an embodiment of the present application, such as Figure 1 As shown, the method may include:

[0029] Step 101: Based on the coverage conditions of the design to be tested, obtain a control flow graph corresponding to each coverage condition.

[0030] Step 102: for any one of the multiple candidate condition groups, based on the control flow graph corresponding to each candidate coverage condition, determine the test correlation between the candidate coverage conditions as the test correlation corresponding to the candidate condition group; the candidate coverage condition is the coverage condition included in the candidate condition group, and the candidate condition group contains at least two of the coverage conditions.

[0031] Step 103: determine the candidate condition group whose corresponding test association degree meets the test requirement as the target group.

[0032] Step 104: Generate test cases based on the target group.

[0033] With respect to the above steps 101 to 104, the embodiments of the present application can be applied to any computer device with data processing capabilities. The above design under test (DUT) can be any software code with test requirements, can be a designed software code, or can be a software code with abnormal operation. The design under test can be selected according to actual needs, and the embodiments of the present application do not limit this.

[0034] The above coverage conditions refer to the conditions that the design to be tested needs to meet, which are often in the form of relational expressions. For example, if the design to be tested is in the following form:

[0035] if((a>5&&b<7)||((c==0)&&(d!=100)))

[0036] return 0;

[0037] else

[0038] return 1;

[0039] For the above design to be tested, there are four relational expressions, namely a>5, b<7, c==0, d!=100. Each expression has two conditions: "satisfied" and "not satisfied". After combination, there are 2 4 = 16 situations, all of which need to be covered, that is, the design to be tested in the above example has 16 coverage conditions.

[0040] Specifically, the embodiment of the present application can parse the source code of the design to be tested, and identify the coverage conditions of the design to be tested based on the operation logic of the code. Alternatively, the embodiment of the present application can also directly obtain the coverage conditions of the design to be tested by receiving information input by relevant personnel, and the embodiment of the present application is not limited to this.

[0041] Among them, the above control flow graph can also be called a control flow graph (CFG), which is used to abstractly represent the execution process of the code, and contains multiple nodes. The flow between the nodes is used to represent all possible flows of the code execution process. Specifically, the embodiment of the present application can obtain the control flow graph corresponding to each coverage condition through a control flow graph generator (for example: Visustin). Specifically, the source code of the design to be tested can be input into Visustin, and the control flow graph corresponding to each coverage condition can be obtained by reading the output data of Visustin.

[0042] It should be noted that the embodiments of the present application can be applicable to a design to be tested with more coverage conditions. One coverage condition corresponds to a control flow graph, so that the control flow graph corresponding to any coverage condition can be used to characterize all possible paths that reach the coverage condition during the execution of the design to be tested.

[0043] For example, Figure 2 is a schematic diagram of a control flow graph provided in an embodiment of the present application, such as Figure 2 As shown, T1 is used to represent the coverage condition of the control flow graph, and nodes 1 to 2 are control nodes, which are used to represent the relational expressions corresponding to the variables during the execution of the program (for example: (a>7), (b!=9) or (c>d), etc.). For a single variable or non-operator, they are converted into relational expressions compared with 0 (such as a is converted to a!=0, !a is converted to a==0). Figure 2 The control flow graph shown is used to characterize the value range of each variable in all possible paths that reach the coverage condition shown in T1.

[0044] Through the control flow graph, the embodiment of the present application can obtain the conditions that the input values ​​of some variables need to meet in order to meet a certain coverage condition. Furthermore, through the control flow graph corresponding to each coverage condition, the overlap degree of the variables involved in different coverage conditions can be obtained, and then if the more nodes of the overlapping variables contained in two control flow graphs and the closer the overlapping variables are to the coverage conditions of each control flow graph, the higher the correlation between the two coverage conditions, then the embodiment of the present application can complete the test of these two coverage conditions by constructing fewer test cases, avoiding the generation of a large number of test cases by constructing and testing each coverage condition separately, and then greatly reducing the test case generation time, and greatly reducing the overall test time for the design to be tested.

[0045] Specifically, the embodiment of the present application can first construct a group of conditions to be selected, each of which contains at least two coverage conditions to be selected. Optionally, the embodiment of the present application can set a quantity limit, that is, the number of coverage conditions to be selected contained in each group of conditions to be selected is greater than 1, and not greater than the quantity limit, so as to avoid the problem of reducing the generation efficiency of test cases caused by too many coverage conditions to be selected contained in the group of conditions to be selected. Exemplarily, if there are four coverage conditions in the design to be tested, respectively denoted as T1, T2, T3, and T4, and the quantity limit is set to 3, then 10 groups of conditions to be selected can be obtained, respectively: (T1, T2), (T1, T3), (T1, T4), (T2, T3), (T2, T4), (T3, T4), (T1, T2, T3), (T1, T2, T4), (T1, T3, T4), (T2, T3, T4).

[0046] Further, the embodiment of the present application can determine the test correlation between each to-be-selected coverage condition for any to-be-selected condition group based on the control flow graph corresponding to each to-be-selected coverage condition, as the test correlation corresponding to the to-be-selected condition group. Wherein, the above-mentioned test correlation is used to characterize the proximity between the test cases required for testing each to-be-selected coverage condition. Specifically, for some large-scale projects, the code logic is extremely complex, and within the limited running time, there will still be a large number of required coverage conditions that are not covered, that is: not tested. These coverage conditions may be interrelated or completely unrelated. If a separate coverage test is performed for each coverage condition, a large amount of test resources will undoubtedly be consumed, especially for multiple interrelated coverage conditions, when a test case search is performed for a certain coverage condition, it will also be close to the solution of another coverage condition (the so-called "solution", i.e., a suitable test case that can realize this coverage condition), and even when a test case that can cover the current coverage condition is found, a test case that can cover two coverage conditions (i.e.: the test case required for these two coverage conditions is extremely close) can be found by searching in this test case neighborhood. At this time, if another coverage test of an associated condition is performed again, it is undoubtedly a waste of resources.

[0047] The embodiment of the present application can determine the degree of proximity of the test cases required for each coverage condition by determining the test correlation between the candidate coverage conditions, and then select the candidate coverage conditions with higher correlation as the coverage conditions that need to be met simultaneously, so that when generating test cases, multiple coverage conditions can be generated.

[0048] Among them, the above-mentioned test requirements can be pre-set, for example, the test correlation can be set to be not less than a preset correlation threshold, or the test correlation can be set to be the largest among all candidate condition groups. It can be set according to actual needs, and the embodiments of the present application do not limit this.

[0049] Optionally, when there are multiple candidate condition groups whose test associations meet the test requirements, the embodiment of the present application may further select the candidate condition group containing the most coverage conditions as the target group.

[0050] Furthermore, the embodiments of the present application can use the coverage conditions contained in the target group as search targets and generate test cases based on the target group. Specifically, the above test case generation method can be based on a genetic algorithm, that is, the initial test cases are continuously iterated, and each generation of test cases is updated based on the fitness of the test cases for the coverage conditions of the target group until the iteration stops. Of course, other iterative algorithms can also be used to use the coverage conditions contained in the target group as search targets to generate test cases with better fitness for the target group, and the embodiments of the present application are not limited to this.

[0051] In summary, the test case generation method provided by the embodiment of the present application obtains the control flow graph corresponding to each of the coverage conditions based on the coverage conditions of the design to be tested; for any of the multiple condition groups to be selected, based on the control flow graph corresponding to each of the coverage conditions to be selected, the test correlation between the selected coverage conditions is determined as the test correlation corresponding to the condition group to be selected; the selected coverage condition is the coverage condition contained in the condition group to be selected, and the condition group to be selected contains at least two of the coverage conditions; the condition group to be selected whose corresponding test correlation meets the test requirements is determined as the target group; and a test case is generated based on the target group. In this way, the embodiment of the present application judges the test correlation between each coverage condition through the control flow graph, and then selects the condition group to be selected whose test correlation meets the test requirements as the target group, and generates a test case through the target group, so that there is no need to generate a separate test case for each coverage condition, and a test case sequence that meets multiple coverage conditions can be generated at one time, thereby greatly reducing the generation time of the test case, improving the test case generation efficiency, and greatly reducing the overall test time for the design to be tested.

[0052] In one implementation, the operation of generating a test case based on the target group may include the following steps:

[0053] S21. Use multiple initial test cases as test cases to be updated, input the multiple test cases to be updated into the design to be tested, and obtain the fitness of each of the test cases to be updated to the design to be tested for a target coverage condition; the target coverage condition is the coverage condition included in the target group.

[0054] S22. Determine a reference test case based on the adaptability of each of the to-be-updated test cases to the target coverage condition.

[0055] S23: For any of the test cases to be updated, update the test case to be updated based on the reference test case.

[0056] S24, determining the updated use case as a new use case to be updated, and re-performing the operation of inputting the multiple use cases to be updated into the design to be tested.

[0057] S25. When the update stop condition is met, determine the test result of the design to be tested.

[0058] Among them, the above-mentioned test case refers to a group of test inputs, execution conditions and expected results compiled for a special purpose, which is used to verify whether the code meets a specific requirement, which can be an assignment to a variable. The above-mentioned initial test case can be randomly generated, or can be randomly written by humans, and the embodiment of the present application does not limit this. Specifically, the number of the above-mentioned initial test cases can be 30, 40 or 60, etc., which can be set according to the actual needs of the design to be tested. It should be noted that since the initial test case can be randomly generated, it is not necessary to consider its verification effect, and thus the time cost of obtaining the initial test case is low.

[0059] Furthermore, the embodiment of the present application can input multiple initial test cases as the test cases to be updated into the design to be tested, and obtain the coverage conditions contained in each test case to be updated for the target group, and the fitness of the design to be tested. Among them, the fitness is used to characterize the coverage degree of the test case to be updated for the target coverage condition. Specifically, the embodiment of the present application can input multiple test cases to be updated into the design to be tested for operation, and obtain the current value of each variable after the design to be tested is run, and judge whether the coverage condition is met based on the current value of each variable, and generate the corresponding fitness based on whether the coverage condition is met.

[0060] Specifically, the embodiment of the present application can calculate the fitness of each use case to be updated for the target coverage condition by the following formula (1):

[0061]

[0062] Among them, the above It is used to characterize the adaptability of the updated use case r to the mth target coverage condition during the nth iteration. m The number of nodes in the control flow graph corresponding to the mth target coverage condition (excluding the node where the target coverage condition is located). The above l(k) is used to characterize the number of layers of the kth node, that is, the minimum number of nodes that the kth node needs to go through to reach the node where the target coverage condition is located. The above α is the first preset value, which can be a constant and can be pre-calibrated for the design to be tested, or set according to actual needs. The above d kUsed to characterize the branch distance of the k-th node.

[0063] Specifically, the above formula (1) is a conditional formula, wherein if condition m has not been covered represents the judgment condition of formula (1), which represents that the target coverage condition has not been covered, that is, after the use case to be updated is input into the design to be tested, whether the mth target coverage condition is achieved, if not achieved, the first calculation formula in formula (1) is executed, if achieved, the fitness is 0. Further, according to the above formula (1), it can be seen that the fitness in the embodiment of the present application is negatively correlated with the test effect on the target coverage condition. When the fitness is 0, the test case has the best test effect on the target coverage condition, and the greater the fitness, the worse the test effect.

[0064] Furthermore, the branch distance can be calculated by the following formula (2):

[0065]

[0066] Wherein, the above d() is used to characterize the branch distance of variables A and B, op is a relational operator, which can be ==, !=, >, ≥, <, ≤, etc. The above abs() is an absolute value function. The above β is a second preset value, which can be a preset constant and can be set according to actual conditions.

[0067] Specifically, in the above formula (2), A and B can be two variables contained in the kth node. The above formula (2) indicates that if the relational expression "A op B" corresponding to the kth node satisfies, then d(A op B) is 0. Otherwise, the absolute value of the difference between the operands A and B plus the constant β is taken as the branch distance of the kth node.

[0068] Furthermore, the embodiments of the present application can select reference use cases based on the fitness of the use cases to be updated to the target coverage conditions. For example, the use case to be updated with the smallest fitness can be directly selected as the reference test case, or it can be randomly selected and set according to actual needs. The embodiments of the present application do not limit this.

[0069] Among them, the above-mentioned update operation can be implemented by a particle swarm algorithm, and of course it can also be implemented by algorithms such as a genetic algorithm, a locust optimization algorithm, etc., and the embodiments of the present application do not limit this. Exemplarily, taking the particle swarm algorithm as an example, the embodiments of the present application can pre-set various parameters of the particle swarm algorithm, such as the number of particles, particle dimensions, inertia factors, learning factors, etc., and one particle represents a use case to be updated. After the particle position is updated, the particle at the new position represents a new use case to be updated. Specifically, for any particle, the position and speed of the particle can be updated according to the historical optimal position of the particle (the use case to be updated with the best fitness generated by the use case to be updated corresponding to the particle during the update process) and the historical optimal position of the particle swarm (reference test case), and the next generation of test cases are generated.

[0070] Furthermore, after obtaining a new use case to be updated, the embodiment of the present application can re-execute the above step S21 to implement update iteration of the use case to be updated based on fitness.

[0071] The above-mentioned update stop condition may be that the number of updates of the use case to be updated reaches a preset number threshold, or that the fitness of the current use case to be tested reaches a preset fitness threshold, etc., which can be set according to actual needs, and the embodiment of the present application does not limit this. Further, when the update stop condition is met, the current updated vector can often better cover the target coverage condition of the target group. At this time, the updated vector can be used to directly test and verify the design to be tested to obtain the test result of the design to be tested.

[0072] In an embodiment of the present application, multiple initial test cases are used as the test cases to be updated, and the multiple test cases to be updated are input into the design to be tested, and the fitness of each test case to be updated for the target coverage condition to the design to be tested is obtained; the target coverage condition is the coverage condition contained in the target group; based on the fitness of each test case to be updated for the target coverage condition, a reference test case is determined; for any of the test cases to be updated, the test case to be updated is updated based on the reference test case; the updated test case is determined as a new test case to be updated, and the operation of inputting the multiple test cases to be updated into the design to be tested is re-executed; when the update stop condition is met, the test result of the design to be tested is determined. There is no need to manually write test cases. By iteratively updating the test cases to be updated, the automatic generation of test cases that meet the requirements can be achieved through the initial test cases, which improves the automation level of test case generation, greatly reduces labor costs, and reduces the time cost of testing the design to be tested.

[0073] In one implementation, after the above operation of obtaining the fitness of each of the to-be-updated use cases for the target coverage condition to the to-be-tested design, the embodiment of the present application may further include:

[0074] S31. For any of the use cases to be updated, if the fitness of the use case to be updated for the target coverage condition is better than the fitness of the use case to be replaced for the target coverage condition, the use case to be updated and the fitness of the use case to be updated are written into the preset record set, and the use case to be replaced is replaced; the use case to be replaced is the use case to be updated stored in the preset record set.

[0075] The above operation of determining the reference test case based on the adaptability of each of the to-be-updated use cases to the target coverage condition may specifically include:

[0076] S32: Determine a reference test case based on the test cases to be updated stored in the preset record set.

[0077] The preset record set may be an external archive, which may be a data structure for storing the better solutions (non-inferior solutions) generated during the search process. Specifically, if the fitness of any use case to be updated is better than the use case to be replaced stored in the preset record set, the embodiment of the present application may use the use case to be updated to replace the use case to be replaced.

[0078] Specifically, when the preset record set is empty, the embodiment of the present application can directly write the current use case to be updated and the fitness. At this time, the preset record set stores the historical optimal positions of all particles. Further, when the preset record set is not empty, the preset record set has stored the historical optimal positions of all particles. The embodiment of the present application needs to use the current use case to be updated to compare with the use case to be replaced stored in the preset record set. When the fitness of the use case to be updated for each target coverage condition is better than that of the use case to be replaced, the use case to be updated is the dominant solution of the use case to be replaced. The use case to be updated and its fitness can be stored in the Archive, and the use case to be replaced and its fitness can be deleted from the Archive.

[0079] Optionally, if the current particle position and any of the solutions stored in the Archive are not mutually dominated solutions, it indicates that the fitness of the use case to be updated corresponding to the current particle is better than the use case to be updated stored in the Archive under at least one target coverage condition. If the Archive is not full, the current particle position and its fitness are stored in the Archive. Otherwise, according to the number of solutions to be deleted and the solution density in the adaptive grid, the corresponding number of solutions are uniformly and randomly deleted from each grid in proportion, and then the current particle and its fitness are stored in the Archive.

[0080] Furthermore, since the preset record set stores use cases to be updated with better fitness, the embodiment of the present application can determine the reference test case based on the use cases to be updated and the fitness stored in the preset record set. For example, it can be randomly selected, or the one with the best fitness can be directly selected, or a selection probability can be assigned to each use case to be updated, and the one with a selection probability greater than the random number can be selected as the reference test case. The specific setting can be made according to actual needs, and the embodiment of the present application does not limit this.

[0081] In an embodiment of the present application, for any of the use cases to be updated, if the fitness of the use cases to be updated for each of the target coverage conditions is better than the fitness of the use cases to be replaced for each of the target coverage conditions, the fitness of the use cases to be updated and the use cases to be updated are written into a preset record set, and the use cases to be replaced are replaced; the use cases to be replaced are the use cases to be updated stored in the preset record set. Based on the use cases to be updated stored in the preset record set, a reference test case is determined. In this way, the test cases with better fitness generated during the update iteration process can be stored based on the preset record set, and the fitness of the stored test cases can be continuously improved through replacement, thereby realizing automatic generation and optimization of test cases.

[0082] In one implementation, the number of dimensions included in the preset record set is consistent with the number of the target coverage conditions. The embodiment of the present application may further include the following steps:

[0083] S41. For any of the target coverage conditions, if the fitness of any of the use cases to be updated for the target coverage condition reaches the target value, the fitness of other use cases to be updated for the target coverage condition are adjusted to the target value, and the dimension corresponding to the target coverage condition in the preset record set is deleted.

[0084] S42. For any use case to be updated stored in the current preset record set, if there are other use cases to be updated in the preset record set whose fitness for each record coverage condition is better than the fitness of the use case to be updated for each record coverage condition, then the use case to be updated is deleted from the current preset record set; the record coverage condition is the target coverage condition corresponding to the dimension contained in the current preset record set.

[0085] The step of determining a reference test case based on the to-be-updated test case stored in the preset record set includes:

[0086] S43: Based on the selection probability of each grid, assign a selection probability to the use cases to be updated contained in each grid.

[0087] S44. Determine a reference test case based on the selection probability of each of the use cases to be updated.

[0088] Among them, the above-mentioned preset record set can contain multiple dimensions, and the number of its dimensions can be consistent with the number of target coverage conditions. Specifically, since the embodiment of the present application is for test case generation for multiple target coverage conditions, and the test case to be updated has a corresponding fitness for each target coverage condition, the embodiment of the present application can use a multi-dimensional preset record set to store the test case to be updated, and different dimensions correspond to the fitness of the test case to be updated for different target coverage conditions.

[0089] The target value may be a preset optimal fitness value. For example, taking the fitness calculation formula (1) as an example, the target value may be 0. Furthermore, when the fitness of any test case to be updated reaches the target value for any target coverage condition, it indicates that there is a test case that can completely cover the target coverage condition. At this time, the dimension corresponding to the target coverage condition may be deleted from the preset record set, and the fitness of other test cases to be updated for the target coverage condition may be adjusted to the target value, thereby realizing dynamic reduction of the target coverage condition and further improving the test case generation efficiency.

[0090] Furthermore, after the preset record set is reduced in dimension, the embodiment of the present invention can update the preset record set again. Specifically, for any use case to be updated stored in the current preset record set, if there are other use cases to be updated in the preset record set whose fitness for each record coverage condition is better than that of the use case to be updated, then the use case to be updated is the dominated solution of other use cases to be updated. At this time, the use case to be updated can be deleted from the preset record set, so that the use case to be updated stored in the preset record set is a solution with better fitness under each target coverage condition. Among them, the above-mentioned record coverage condition refers to the target coverage condition corresponding to the dimension contained in the current preset record set.

[0091] Furthermore, the embodiment of the present application can also divide the preset record set into grids. Specifically, each dimension can be divided, and when each dimension is divided, the maximum and minimum values ​​of the fitness corresponding to this dimension of all non-dominated solutions are found, and the [minimum value, maximum value] interval is divided into a set number of sub-intervals. In this way, all non-inferior solutions are divided into different grids.

[0092] For example, Figure 3 is a schematic diagram of the structure of a preset record set provided in an embodiment of the present application, such as Figure 3 As shown, taking the case where there are two target coverage conditions and the number of sub-intervals is 3 as an example, the two-dimensional preset record set is divided into 9 grids. Figure 3Each point in represents a use case to be updated (non-inferior solution), f1 represents the first target coverage condition, and f2 represents the second target coverage condition. min Characterizes the minimum value of the fitness of the first target coverage condition among the stored use cases to be updated, f1 max Characterizes the maximum value of the fitness of the first target coverage condition in the stored use cases to be updated, f2 min The minimum value of the fitness of the second target coverage condition among the stored use cases to be updated, f2 max Indicates the maximum value of the fitness of the second target coverage condition in the stored use cases to be updated.

[0093] Further, Figure 4 is a schematic diagram of the structure of another preset record set provided in an embodiment of the present application, such as Figure 4 As shown, Figure 4 The left side is a schematic diagram of adding a new use case to be updated (new solution), such as Figure 3 As shown in , the new solution covers the first target condition, that is, the value of the new solution in the first dimension is 0. At this time, the fitness of other use cases to be updated in the first dimension can be modified to 0, which is equivalent to deleting the first dimension. At this time, after dimensionality reduction, only one dimension remains in the preset record table, and by deleting the dominated solutions in the preset record table, only one optimal solution is retained in this dimension, as shown in Figure 4 Shown on the right.

[0094] Furthermore, the embodiment of the present application may adopt a probabilistic selection method when determining the reference test case. Specifically, the preset record set may be divided into grids, and a selection probability may be assigned to each grid. In one case, the selection probability of each grid may be equal. Furthermore, the embodiment of the present application may evenly distribute the selection probability of each grid to the test cases to be updated contained in the grid. Since the number of test cases to be updated contained in each grid may be different, the selection probability of the test cases to be updated may be different.

[0095] Furthermore, the embodiment of the present application can determine the reference test case according to the selection probability of each use case to be updated. Specifically, the selection can be performed by a uniform random method, that is, generating a uniform random number and determining the use case to be updated with a selection probability not less than the uniform random number as the reference test case.

[0096] Alternatively, a roulette wheel selection algorithm can also be used, which can be set according to actual needs, and the embodiment of the present application does not limit this. Specifically, the use cases to be updated in the preset record set can be sorted in order from high to low in terms of selection probability, and the use cases to be updated in the sorting result are arranged in descending order according to the selection probability. According to the sorting result and the selection probability of each use case to be updated, a cumulative probability is generated for each use case to be updated. Among them, the cumulative probability refers to the sum of the selection probabilities of the current use case to be updated and the use case to be updated before the current use case to be updated. For example, there are 5 use cases to be updated a, b, c, d, e, and the selection probabilities are 0.18, 0.16, 0.13, 0.11, and 0.02, respectively. The cumulative probability of a is 0.18, the cumulative probability of b is 0.34, the cumulative probability of c is 0.47, the cumulative probability of d is 0.58, and the cumulative probability of e is 0.60.

[0097] On this basis, the embodiment of the present invention can select the use cases to be updated in the preset record set based on the cumulative probability. Specifically, the selection operation can be performed on the preset record set based on the cumulative probability. Specifically, the above selection operation can be: generate a random number, and the value range of the random number can be [0, 1]. Further, one use case to be updated is used in turn in the order in the sorting result to compare with the random number. When the cumulative probability of the use case to be updated is less than the random number, the next use case to be updated is used to continue to compare with the random number until the cumulative probability of the currently used use case to be updated is not less than the random number, then the use case to be updated is determined as the selected reference test case.

[0098] In an embodiment of the present application, for any of the target coverage conditions, when the fitness of any of the to-be-updated use cases for the target coverage condition reaches the target value, the fitness of other to-be-updated use cases for the target coverage condition are all adjusted to the target value, and the dimension corresponding to the target coverage condition in the preset record set is deleted; the preset record set is divided into grids, and a selection probability is assigned to each of the grids; based on the selection probability of each of the grids, a selection probability is assigned to the to-be-updated use cases contained in each of the grids; based on the selection probability of each of the to-be-updated use cases, a reference test case is determined. In this way, the target coverage condition can be dynamically adjusted through the preset record set, further improving the efficiency of test case generation.

[0099] In one implementation, the operation of determining the test association between the candidate coverage conditions based on the control flow graph corresponding to the candidate coverage conditions may include:

[0100] S51, obtaining shared variables in each of the control flow graphs to be selected, and obtaining association factors of the shared variables in each of the control flow graphs to be selected; the control flow graph to be selected is a control flow graph corresponding to the coverage condition to be selected.

[0101] S52: Based on any of the shared variables, determine the smallest correlation factor among the correlation factors of the shared variable in each of the to-be-selected control diagrams as the target correlation factor of the shared variable.

[0102] S53: Determine the sum of the target association factors of the shared variables as the test association degree between the candidate coverage conditions.

[0103] The above-mentioned shared variables refer to variables that exist in multiple candidate control flow graphs. The above-mentioned correlation factor is used to characterize the importance of the variable in each candidate coverage condition, that is, the higher the correlation factor, the more important the variable is in each candidate coverage condition, and the variable needs to be considered when constructing the test case.

[0104] Optionally, the operation of obtaining the correlation factor of the shared variable in each of the control flow graphs to be selected can be obtained by the following steps in the embodiment of the present application:

[0105] S511. For any of the control flow graphs to be selected, obtain the existence factor of the shared variable in each node included in the control flow graph to be selected;

[0106] S512, determining the sum of the existence factors of the shared variable in each node as the association factor of the shared variable in the to-be-selected control flow graph;

[0107] The existence factor of the shared variable in any node is calculated by the following formula (3):

[0108]

[0109] The k is the kth node in the control flow graph to be selected, the m is the mth control flow graph to be selected, the v is the vth shared variable, the q is the existence factor, the l(k) is the number of layers of the kth node in the control flow graph to be selected, and the is the existence state of the v-th shared variable in the k-th node. The above existence state is used to indicate whether it exists, if it exists, it is 1, otherwise it is 0. For example, for a certain node, its relationship expression is A>B, then for variable A, this value is 1, and for variable C, this value is 0.

[0110] Furthermore, after obtaining the existence factor of the shared variable, the sum of the existence factors of the shared variable in each node can be determined as the association factor of the shared variable in the candidate control flow graph. Specifically, as shown in the following formula (4):

[0111]

[0112] Among them, the above p m (v) is used to characterize the correlation factor of the vth variable in the control flow graph corresponding to the mth target coverage condition. m Used to represent the number of nodes contained in the control flow graph corresponding to the mth target coverage condition (excluding the nodes to which the target coverage condition belongs).

[0113] Furthermore, after obtaining the correlation factor of the shared variable, the smallest correlation factor among the correlation factors of the shared variable in each candidate control chart can be determined as the target correlation factor, and then the sum of the target correlation factors of each shared variable can be determined as the test correlation between each candidate coverage condition.

[0114] Specifically, as shown in the following formula (5):

[0115]

[0116] Wherein, the above P(a,b,c) represents the test correlation between the candidate coverage conditions a, b, and c. The above s is used to represent the ordinal number of the shared variable. Accordingly, the above v s The above S(a,b,c) is used to represent the number of shared variables existing in the candidate coverage conditions a, b, and c.

[0117] In an embodiment of the present application, for a shared variable, the existence factor of the node is determined based on whether it exists in each node of the control flow graph and the number of node layers, and the algebraic sum of the existence factors of all nodes is used as the association factor of the variable in the control flow graph. The smallest association factor of this variable in multiple target condition control flow graphs is selected as the shared association factor of this variable, and the shared association factors of all shared variables involved are added as the test association of multiple candidate control graphs. The selection of intelligent target groups can be achieved through the association, without the need for manual selection based on experience, avoiding selection errors caused by subjective factors, and more efficiently searching for effective test cases, reducing invalid test processes and improving verification efficiency.

[0118] It should be noted that the completeness of code testing is extremely important to code quality, and the cost of code testing usually exceeds 50% of the total R&D cost. This has led to the industry's gradual emphasis on the research of code testing methods, and many related methodologies, tools and algorithms have emerged. Among them, automated code testing has gradually become a research hotspot because it can greatly improve test efficiency and reduce R&D costs. In the field of automated code testing, the automatic generation of test cases is the key. Drawing on the optimization experience in the control field, a series of intelligent search algorithms have been introduced into the automated generation process of test cases to improve the efficiency of test case generation, including genetic algorithms, particle swarm algorithms, ant colony algorithms, and so on.

[0119] The automatic generation technology of test cases involves line coverage testing, branch coverage testing, condition coverage testing, path coverage testing, etc. of code testing. Among them, the application of condition coverage has gradually gained attention because it involves the processing of difficult-to-cover conditions such as boundary testing and exception testing. In the process of code condition coverage testing, there is usually a situation of condition combination coverage, that is, there are multiple coverage conditions that need to be tested. These conditions may be related to each other or completely unrelated. If a separate coverage test is performed for each condition, it will undoubtedly consume a lot of testing resources.

[0120] Figure 5 is a flow chart of a test case generation process provided by an embodiment of the present application, such as Figure 5 As shown, the code can be first statically analyzed to construct a control flow graph, which can be specifically implemented by visustin. Further, the correlation of the conditions (or coverage conditions) is analyzed according to the control flow graph to determine the target condition (corresponding to the target group). Figure 5 In the example of particle swarm algorithm, the test case is updated, and then the multi-objective particle swarm algorithm can be initialized, and the initial test case is generated. The initial test case is input into the DUT verification environment to run and the fitness of the particle swarm is calculated. The historical optimal position and fitness of the individual particle and the historical optimal position and fitness of the particle swarm are updated to determine whether the target condition is covered or whether the number of iterations reaches the limit. If not, the particle swarm position and speed are updated according to the particle swarm algorithm, and the next generation of test cases is generated and input into the DUT verification environment to run. If so, the current particle is determined as the final target test case, and the DUT is tested using the target test case to obtain the test result.

[0121] Specifically, when the particle swarm algorithm is used to update the test case, it can be achieved by the following formula (6):

[0122]

[0123] in, Characterizes the speed of the mth particle at the nth iteration, which is a vector, and each dimension corresponds to the speed of each dimension of the position. n The inertia weight representing the nth iteration can be set based on the coverage requirement. In one case, the inertia weight can also be a constant, which is not limited in the present embodiment. Represents the position of the mth particle at the nth iteration. The above Wm represents the individual optimal position of the mth particle, and the above Wg represents the group optimal position. The individual learning factor and the group learning factor that respectively characterize the m-th particle in the n-th iteration can also be set according to actual needs. In one case, the individual learning factor and the group learning factor can both be constants.

[0124] In summary, in the embodiments of the present application, the automatic generation of test cases is realized, which reduces the workload of verification personnel on the one hand, and improves the verification efficiency by searching for effective test cases more efficiently and reducing invalid test processes on the other hand. At the same time, due to the inclusion of an intelligent search process, it is easier to achieve the generation of corner test cases, and the test completeness is better. At the same time, an optimized search for test paths is performed for multiple target coverage conditions, and the corresponding fitness function and Archive update strategy are designed according to the characteristics of the code condition coverage test. Due to the multi-objective properties of the method and the dynamic reduction mechanism of the target coverage conditions, the test case generation efficiency can be improved. Through the evaluation mechanism of the correlation between the target condition control flow charts, and selecting multiple target conditions with large correlation for automatic generation of test cases, the algorithm convergence speed can be accelerated and the overall test time can be reduced.

[0125] Figure 6 is a structural diagram of a test case generation device provided in an embodiment of the present application, such as Figure 6 As shown, the device 20 may include:

[0126] A first acquisition module 201 is used to acquire a control flow graph corresponding to each coverage condition based on the coverage conditions of the design to be tested;

[0127] A first determination module 202 is used to determine, for any one of the multiple candidate condition groups, the test association between the candidate coverage conditions based on the control flow graph corresponding to each candidate coverage condition, as the test association corresponding to the candidate condition group; the candidate coverage condition is the coverage condition included in the candidate condition group, and the candidate condition group includes at least two of the coverage conditions;

[0128] The second determination module 203 is used to determine the candidate condition group whose corresponding test association degree meets the test requirement as the target group;

[0129] The generating module 204 is used to generate a test case based on the target group.

[0130] Optionally, the generating module includes:

[0131] An input submodule, used to take a plurality of initial test cases as test cases to be updated, input the plurality of test cases to be updated into the design to be tested, and obtain the fitness of each of the test cases to be updated to the design to be tested with respect to a target coverage condition; the target coverage condition is a coverage condition included in the target group;

[0132] A third determination submodule is used to determine a reference test case based on the adaptability of each of the to-be-updated test cases to the target coverage condition;

[0133] An updating submodule, configured to update any of the test cases to be updated based on the reference test case;

[0134] An execution module, configured to determine the updated use case as a new use case to be updated, and re-execute the operation of inputting the multiple use cases to be updated into the design to be tested;

[0135] The fourth determination submodule is used to determine the test result of the design to be tested when the update stop condition is met.

[0136] Optionally, the device further comprises:

[0137] A writing module, for writing the fitness of any of the use cases to be updated and the use cases to be updated into a preset record set, and replacing the use case to be replaced, if the fitness of the use case to be updated for each of the target coverage conditions is better than the fitness of the use case to be replaced for each of the target coverage conditions; the use case to be replaced is the use case to be updated stored in the preset record set;

[0138] The third determining submodule is specifically used for:

[0139] Based on the test cases to be updated stored in the preset record set, a reference test case is determined.

[0140] Optionally, the number of dimensions included in the preset record set is consistent with the number of target coverage conditions; and the device further includes:

[0141] An adjustment module, for adjusting the fitness of other use cases to be updated for the target coverage condition to the target value for any of the target coverage conditions, and deleting the dimension corresponding to the target coverage condition in the preset record set, if the fitness of any of the use cases to be updated for the target coverage condition reaches the target value;

[0142] A deletion module is used to delete any use case to be updated stored in the current preset record set. If there are other use cases to be updated in the preset record set whose fitness for each record coverage condition is better than the fitness of the use case to be updated for each record coverage condition, the use case to be updated will be deleted from the current preset record set; the record coverage condition is the target coverage condition corresponding to the dimension contained in the current preset record set.

[0143] The third determining submodule is specifically used for:

[0144] Dividing the preset record set into grids, and assigning a selection probability to each of the grids;

[0145] Based on the selection probability of each grid, assigning a selection probability to the use cases to be updated contained in each grid;

[0146] Based on the selection probability of each of the use cases to be updated, a reference test case is determined.

[0147] Optionally, the first determining module includes:

[0148] A second acquisition submodule is used to acquire shared variables in each of the control flow graphs to be selected, and to acquire correlation factors of the shared variables in each of the control flow graphs to be selected; the control flow graph to be selected is a control flow graph corresponding to the coverage condition to be selected;

[0149] A fifth determination submodule is used to determine, based on any of the shared variables, the smallest correlation factor among the correlation factors of the shared variable in each of the to-be-selected control diagrams as the target correlation factor of the shared variable;

[0150] The sixth determination submodule is used to determine the sum of the target association factors of the shared variables as the test association degree between the candidate coverage conditions.

[0151] Optionally, the second acquisition submodule is specifically used to:

[0152] For any of the control flow graphs to be selected, obtaining the existence factor of the shared variable in each node included in the control flow graph to be selected;

[0153] Determine the sum of the existence factors of the shared variable in each of the nodes as the association factor of the shared variable in the selected control flow graph;

[0154] The existence factor of the shared variable in any node is calculated by the following formula:

[0155]

[0156] The k is the kth node in the control flow graph to be selected, the m is the mth control flow graph to be selected, the v is the vth shared variable, the q is the existence factor, the l(k) is the number of layers of the kth node in the control flow graph to be selected, and the is the existence status of the vth shared variable in the kth node.

[0157] Optionally, the input submodule is specifically used to:

[0158]

[0159] Said It is used to characterize the adaptability of the use case r to be updated to the mth target coverage condition during the nth iteration. m is used to characterize the number of nodes in the control flow graph corresponding to the mth target coverage condition; the l(k) is used to characterize the number of layers of the control flow graph corresponding to the kth node under the mth target coverage condition; the α is a first preset value; the d k Used to characterize the branch distance of the kth node;

[0160] The branch distance is calculated by the following formula:

[0161]

[0162] The d(A op B) is used to represent the branch distance between variables A and B, and op represents a relational operator; the abs(AB) represents the absolute value of the difference between A and B; and β is a second preset value.

[0163] In summary, the test case generation device provided by the embodiment of the present application obtains the control flow graph corresponding to each of the coverage conditions based on the coverage conditions of the design to be tested; for any of the multiple condition groups to be selected, based on the control flow graph corresponding to each of the coverage conditions to be selected, the test correlation between the selected coverage conditions is determined as the test correlation corresponding to the condition group to be selected; the selected coverage condition is the coverage condition contained in the condition group to be selected, and the condition group to be selected contains at least two of the coverage conditions; the condition group to be selected whose corresponding test correlation meets the test requirements is determined as the target group; and a test case is generated based on the target group. In this way, the embodiment of the present application judges the test correlation between each coverage condition through the control flow graph, and then selects the condition group to be selected whose test correlation meets the test requirements as the target group, and generates a test case through the target group, so that there is no need to generate a separate test case for each coverage condition, and a test case sequence that meets multiple coverage conditions can be generated at one time, thereby greatly reducing the test case generation time, improving the test case generation efficiency, and greatly reducing the overall test time for the design to be tested.

[0164] The present application also provides an electronic device, see Figure 7 , including: a processor 3001, a memory 3002, and a computer program 30021 stored in the memory and executable on the processor, wherein the processor implements the method of the aforementioned embodiment when executing the program.

[0165] The present application also provides a readable storage medium. When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device can execute the method of the aforementioned embodiment.

[0166] The present application also provides a computer program product, including a computer program / instruction, which implements the method of the aforementioned embodiment when executed by a processor.

[0167] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0168] The algorithm and display provided herein are not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing such systems. In addition, the application is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to realize the content of the application described herein, and the description of the specific language above is for the purpose of disclosing the best mode of implementation of the application.

[0169] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0170] Similarly, it should be understood that in order to streamline the present application and help understand one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present application, the various features of the present application are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following intention: the claimed application requires more features than the features clearly stated in each claim. More specifically, as reflected in the claims below, the inventive aspects are less than all the features of the single embodiment disclosed above. Therefore, the claims following the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present application.

[0171] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0172] The various component embodiments of the present application can be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) can be used in practice to implement some or all functions of some or all components in the sorting device according to the present application. The present application can also be implemented as a device or apparatus program for executing part or all of the methods described herein. Such a program implementing the present application can be stored on a computer-readable medium, or can have the form of one or more signals. Such a signal can be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0173] It should be noted that all actions of acquiring signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the country where they are located and with the authorization given by the owner of the corresponding device.

[0174] It should be noted that the above embodiments illustrate the present application rather than limit the present application, and that those skilled in the art may design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets should not be constructed as a limitation to the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of multiple such elements. The present application may be implemented by means of hardware including several different elements and by means of a suitably programmed computer. In a unit claim that lists several devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names.

[0175] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0176] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present application should be included in the protection scope of the present application.

[0177] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.

Claims

1. A test case generation method, characterized in that: The method comprises: Based on the coverage conditions of the design to be tested, obtaining a control flow graph corresponding to each of the coverage conditions; For any one of the multiple candidate condition groups, based on the control flow graph corresponding to each candidate coverage condition, determine the test association between the candidate coverage conditions as the test association corresponding to the candidate condition group; the candidate coverage condition is the coverage condition included in the candidate condition group, and the candidate condition group includes at least two of the coverage conditions; Determine the candidate condition group whose corresponding test correlation degree meets the test requirements as the target group; Test cases are generated based on the target group.

2. The method according to claim 1, characterized in that: The generating of test cases based on the target group includes: Taking a plurality of initial test cases as test cases to be updated, inputting the plurality of test cases to be updated into the design to be tested, and obtaining the fitness of each of the test cases to be updated for the design to be tested with respect to a target coverage condition; the target coverage condition is a coverage condition included in the target group; Determining a reference test case based on the adaptability of each of the to-be-updated test cases to the target coverage condition; For any of the test cases to be updated, updating the test case to be updated based on the reference test case; Determine the updated use case as a new use case to be updated, and re-execute the operation of inputting the multiple use cases to be updated into the design to be tested; When the update stop condition is met, a test result of the design to be tested is determined.

3. The method according to claim 2, characterized in that After obtaining the fitness of each of the to-be-updated use cases for the design to be tested with respect to the target coverage condition, the method further includes: For any of the use cases to be updated, if the fitness of the use case to be updated for each of the target coverage conditions is better than the fitness of the use case to be replaced for each of the target coverage conditions, the use case to be updated and the fitness of the use case to be updated are written into the preset record set, and the use case to be replaced is replaced; the use case to be replaced is the use case to be updated stored in the preset record set; The step of determining a reference test case based on the adaptability of each of the to-be-updated test cases to the target coverage condition comprises: Based on the test cases to be updated stored in the preset record set, a reference test case is determined.

4. The method according to claim 3, characterized in that: The number of dimensions included in the preset record set is consistent with the number of target coverage conditions; the method further includes: For any of the target coverage conditions, if the fitness of any of the to-be-updated use cases for the target coverage condition reaches the target value, the fitness of other to-be-updated use cases for the target coverage condition are adjusted to the target value, and the dimension corresponding to the target coverage condition in the preset record set is deleted; For any use case to be updated stored in the current preset record set, if there are other use cases to be updated in the preset record set whose fitness for each record coverage condition is better than the fitness of the use case to be updated for each record coverage condition, then the use case to be updated is deleted from the current preset record set; the record coverage condition is the target coverage condition corresponding to the dimension included in the current preset record set; The step of determining a reference test case based on the to-be-updated test case stored in the preset record set includes: Dividing the preset record set into grids, and assigning a selection probability to each of the grids; Based on the selection probability of each grid, assigning a selection probability to the use cases to be updated contained in each grid; Based on the selection probability of each of the use cases to be updated, a reference test case is determined.

5. The method according to claim 1, characterized in that The step of determining the test association between the candidate coverage conditions based on the control flow graph corresponding to the candidate coverage conditions includes: Acquire the shared variables in each of the control flow graphs to be selected, and acquire the correlation factors of the shared variables in each of the control flow graphs to be selected; the control flow graph to be selected is the control flow graph corresponding to the coverage condition to be selected; Based on any of the shared variables, determining the smallest correlation factor of the shared variable in each of the to-be-selected control diagrams as the target correlation factor of the shared variable; The sum of the target association factors of the shared variables is determined as the test association degree between the candidate coverage conditions.

6. The method according to claim 5, characterized in that The obtaining of the correlation factor of the shared variable in each of the control flow graphs to be selected includes: For any of the control flow graphs to be selected, obtaining the existence factor of the shared variable in each node included in the control flow graph to be selected; Determine the sum of the existence factors of the shared variable in each of the nodes as the association factor of the shared variable in the selected control flow graph; The existence factor of the shared variable in any node is calculated by the following formula: The k is the kth node in the control flow graph to be selected, the m is the mth control flow graph to be selected, the v is the vth shared variable, the q is the existence factor, the l(k) is the number of layers of the kth node in the control flow graph to be selected, and the is the existence status of the vth shared variable in the kth node.

7. The method according to claim 2, characterized in that The obtaining of the adaptability of each of the to-be-updated use cases to the to-be-tested design according to the target coverage condition includes: Said It is used to characterize the adaptability of the use case r to be updated to the mth target coverage condition during the nth iteration. m is used to characterize the number of nodes in the control flow graph corresponding to the mth target coverage condition; the l(k) is used to characterize the number of layers of the control flow graph corresponding to the kth node under the mth target coverage condition; the α is a first preset value; the d k Used to characterize the branch distance of the kth node; The branch distance is calculated by the following formula: The d(A op B) is used to represent the branch distance between variables A and B, and op represents a relational operator; the abs(AB) represents the absolute value of the difference between A and B; and β is a second preset value.

8. A test case generating device, characterized in that: The device comprises: A first acquisition module is used to acquire a control flow graph corresponding to each coverage condition based on the coverage conditions of the design to be tested; A first determination module is used to determine, for any one of the multiple candidate condition groups, the test association between the candidate coverage conditions based on the control flow graph corresponding to each candidate coverage condition, as the test association corresponding to the candidate condition group; the candidate coverage condition is the coverage condition included in the candidate condition group, and the candidate condition group includes at least two of the coverage conditions; A second determination module is used to determine the candidate condition group whose corresponding test association degree meets the test requirement as the target group; A generating module is used to generate test cases based on the target group.

9. An electronic device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 7 is implemented.

10. A readable storage medium, characterized in that: When the instructions in the storage medium are executed by a processor of an electronic device, the electronic device is enabled to execute any one of the methods described in claims 1-7.