Method, device, electronic device and storage medium for generating test cases

By selecting a set of target use cases that meet the target coverage, and using an artificial intelligence model to optimize the chip verification process, the problem of low verification efficiency caused by use case redundancy is solved, and efficient chip verification is achieved.

CN120144379BActive Publication Date: 2026-04-10BEIJING X RING TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING X RING TECHNOLOGY CO LTD
Filing Date
2025-02-26
Publication Date
2026-04-10

AI Technical Summary

Technical Problem

In existing technologies, the verification process suffers from low efficiency due to redundant test cases, and cannot effectively cover all functional points of the chip.

Method used

By determining the candidate test case set and the check item set of the object under test, the target test case set that meets the target coverage is selected. Then, using artificial intelligence models such as evolutionary algorithms, reward models, penalty models, or greedy algorithms, appropriate target test cases are selected from the candidate test cases for verification.

Benefits of technology

This improved the efficiency of chip verification, reduced test case redundancy, and ensured the effectiveness of coverage during the verification process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120144379B_ABST
    Figure CN120144379B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and device for generating test cases, electronic equipment and storage medium, and relates to the technical field of chip verification. The method comprises the following steps: determining a candidate case set corresponding to a to-be-tested object and a check item set; determining a first check item corresponding to a candidate case in the candidate case set; determining a target case set corresponding to the to-be-tested object from the candidate case set according to the check item set and the first check item corresponding to the candidate case, wherein the coverage rate of the target case set meets a target coverage rate. Therefore, before verifying the to-be-tested object, the target case set meeting the demand in coverage rate and having a small number of cases can be selected from a large number of candidate cases based on the first check item corresponding to each candidate case and the preset check item set, so as to avoid case redundancy as much as possible, and thus the verification efficiency can be improved when the to-be-tested object is verified by using the target case set.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the chip verification technical field, and particularly relates to a method and device for generating test cases, an electronic device and a storage medium. BACKGROUND

[0002] Verification of a chip is a crucial link in a semiconductor manufacturing process, which ensures the performance, reliability and security of the chip in actual application.

[0003] In the related art, in order to improve the verification efficiency of the chip, the use case for verifying the chip is mostly a use case randomly generated according to the functional requirement of the chip. In order to achieve the expected verification coverage, a large number of randomly generated use cases are often used to verify the chip. However, a large number of use cases may hit the same function point, resulting in use case redundancy, and thus leading to low verification efficiency. SUMMARY

[0004] The present disclosure aims to at least solve one of the technical problems in the related art to some extent.

[0005] The first aspect of the present disclosure provides a method for generating test cases, comprising:

[0006] determining a candidate use case set and a check item set corresponding to a measured object;

[0007] determining a first check item corresponding to a candidate use case in the candidate use case set, wherein the first check item belongs to the check item set;

[0008] determining a target use case set corresponding to the measured object from the candidate use case set according to the check item set, the first check item corresponding to the candidate use case, and the target use case set corresponding to a coverage rate satisfying a target coverage rate.

[0009] The second aspect of the present disclosure provides a device for generating test cases, comprising:

[0010] a first determination module configured to determine a candidate use case set and a check item set corresponding to a measured object;

[0011] a second determination module configured to determine a first check item corresponding to a candidate use case in the candidate use case set, wherein the first check item belongs to the check item set;

[0012] a third determination module configured to determine a target use case set corresponding to the measured object from the candidate use case set according to the check item set, the first check item corresponding to the candidate use case, and the target use case set corresponding to a coverage rate satisfying a target coverage rate.

[0013] The third aspect of the present disclosure provides a chip, comprising the chip being obtained through a target use case set, and the target use case set being obtained through the method for generating test cases provided in the first aspect.

[0014] The fourth aspect of the present disclosure provides a terminal, comprising the chip provided in the third aspect.

[0015] The fifth aspect of the present disclosure provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for generating test cases provided in the first aspect of the present disclosure when executing the program.

[0016] The sixth aspect of the present disclosure provides a computer readable storage medium, storing a computer program, wherein the computer program is executable on a processor to implement the method for generating test cases provided in the first aspect of the present disclosure.

[0017] The seventh aspect of the present disclosure provides a computer program product, comprising a computer program, wherein the computer program is executable on a processor to implement the method for generating test cases provided in the first aspect of the present disclosure.

[0018] The method, device, electronic device and storage medium for generating test cases provided in the present disclosure have the following beneficial effects:

[0019] In the embodiments of the present disclosure, the candidate use case set and the inspection item set corresponding to the measured object are determined, then the first inspection item corresponding to the candidate use case in the candidate use case set is determined, and finally the target use case set with the coverage rate meeting the target coverage rate is determined from the candidate use case set according to the inspection item set and the first inspection item corresponding to the candidate use case. Therefore, before the measured object is verified, the target use case set with the coverage rate meeting the demand and a small number of target use cases can be screened from a large number of candidate use cases based on the first inspection item corresponding to each candidate use case and the preset inspection item set, so that the use case redundancy can be avoided as much as possible, and the verification efficiency can be improved when the measured object is verified by using the target use case set.

[0020] Additional aspects and advantages of the present disclosure will be described in part in the description that follows, and some will become apparent from the description that follows, or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0021] The above and / or additional aspects and advantages of the present disclosure will become apparent and be readily understood from the following description, taken in conjunction with the accompanying drawings, in which:

[0022] Figure 1A flowchart of a method for generating a test case provided by an embodiment of the present disclosure is shown in FIG. 1.

[0023] Figure 2 A flowchart of a method for generating a test case provided by another embodiment of the present disclosure is shown in FIG. 2.

[0024] Figure 3 A flowchart of a method for generating a test case provided by another embodiment of the present disclosure is shown in FIG. 3.

[0025] Figure 4 A flowchart of a method for generating a test case provided by another embodiment of the present disclosure is shown in FIG. 4.

[0026] Figure 5 A flowchart of a method for generating a test case provided by another embodiment of the present disclosure is shown in FIG. 5.

[0027] Figure 6 A structural diagram of an apparatus for generating a test case provided by another embodiment of the present disclosure is shown in FIG. 6.

[0028] Figure 7 A structural diagram of a chip provided by an embodiment of the present disclosure is shown in FIG. 7.

[0029] Figure 8 A block diagram of an exemplary electronic device suitable for implementing an embodiment of the present disclosure is shown in FIG. 8. DETAILED DESCRIPTION

[0030] Some embodiments of the present disclosure will be described in detail with reference to the drawings, wherein the same reference numerals represent the same elements throughout the several views. The following description of the various examples is not intended to limit the scope of the present disclosure, but is merely intended to provide an example of how the various examples described herein can be implemented. The description of features in the following description should be considered in the context of the description of the features and concepts described herein and by reference to the drawings.

[0031] The implementations described in the following detailed description of some embodiments of the present disclosure are not meant to represent all implementations consistent with the present disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0032] The method, apparatus, electronic device and storage medium for generating a test case of an embodiment of the present disclosure are described below with reference to the accompanying drawings.

[0033] Figure 1A flowchart of a method for generating a test case according to an embodiment of the present disclosure is shown in FIG. 1.

[0034] An embodiment of the present disclosure illustrates the method for generating a test case in a device for generating a test case. The device for generating a test case can be applied to any electronic device or chip, so that the electronic device or chip can perform the function of generating a test case.

[0035] As shown in FIG. 2, the method for generating a test case can include the following steps. Figure 1

[0036] Step 101: Determine a candidate case set and a check item set corresponding to a to-be-tested object.

[0037] The to-be-tested object can be hardware, such as a chip, a processor, a graphics card, a memory, etc. The to-be-tested object can also be software, such as an application program, etc. The present disclosure does not limit the to-be-tested object.

[0038] The candidate case set includes a plurality of candidate cases. The candidate cases can be cases generated in advance according to test points.

[0039] In some embodiments, the candidate cases can be generated manually according to test points, or can be generated automatically according to test points. The present disclosure does not limit the candidate cases.

[0040] In some embodiments, the test points include single test points and combined test points. The test points are used to construct cases, and the single test points are input variables, output variables, or intermediate variables corresponding to the to-be-tested object. The combined test points can be combinations of single test points.

[0041] The check item set can include one or more check items corresponding to the test points. The check items are values or value combinations corresponding to the test points.

[0042] For example, if the test points of interest of the to-be-tested object are single test point A, single test point B, and combined test point A and B, the values of single test point A are {1, 2, 3}, the values of single test point B are {4, 5, 6}, and the combined values of combined test point A and B are {[1, 5], [3, 4]}. The check item set includes 8 check items, which are [A] = [1]; [A] = [2]; [A] = [3]; [B] = [4]; [B] = [5]; [B] = [6]; [A, B] = [1, 5]; and [A, B] = [3, 4].

[0043] ​In some embodiments, the types of the test point A and the test point B can be the same. For example, both of them can be input test points, intermediate test points, or output test points. The types of the test point A and the test point B can also be different. For example, the test point A is an input test point, and the test point B is an output test point, and so on. The present disclosure does not limit this.

[0044] In step 102, the first check item corresponding to the candidate use case in the candidate use case set is determined, wherein the first check item belongs to the check item set.

[0045] In some embodiments, the number of the first check items corresponding to one candidate use case can be one or multiple. The present disclosure does not limit this.

[0046] In some embodiments, the value of the input variable in the candidate use case can be input into the measured object to obtain the output result of the measured object, and then the output result can be processed to obtain the value of the intermediate variable and the value of the output variable. Subsequently, the first check item corresponding to the candidate use case can be determined according to the value of the input variable, the value of the output variable, the value of the intermediate variable, and the check item set.

[0047] For example, if the check item set includes [A] = [1]; [A] = [2]; [A] = [3]; [B] = [4]; [B] = [5]; [B] = [6]; [A, B] = [1, 5]; [A, B] = [3, 4]. The value of variable A corresponding to a certain candidate use case is 1, and the value of variable B is 5. The corresponding first check item includes [A] = [1]; [B] = [5]; [A, B] = [1, 5] three check items.

[0048] In step 103, the target use case set corresponding to the measured object is determined from the candidate use case set according to the check item set and the first check item corresponding to the candidate use case.

[0049] In some embodiments, the coverage rate corresponding to the target use case set satisfies the target coverage rate in the case where the coverage rate corresponding to the target use case set is greater than or equal to the target coverage rate.

[0050] In some embodiments, the coverage rate corresponding to the target use case set is the ratio of the first number to the second number, the first number is the number of all different check items corresponding to the target use case set, and the second number is the number of all check items in the check item set.

[0051] It should be noted that the coverage corresponding to the candidate use case set can be greater than the target coverage, but since there are many use cases in the candidate use case set, there can be a case where the first check items corresponding to two candidate use cases are repeated, so in the embodiment of the present disclosure, the target use cases that meet the coverage requirement and have a smaller number can be selected by screening the candidate use cases in the candidate use case set, and the measured object is verified to improve the verification efficiency.

[0052] The coverage corresponding to the candidate use case set can be the ratio between the fifth number and the second number, and the fifth number is the number of all different check items corresponding to the candidate use case set.

[0053] The target coverage can be a pre-set value, such as 0.98, 1, 0.99, etc. The present disclosure does not limit this.

[0054] In some embodiments, the target coverage can also be determined according to the functional complexity of the measured object and the required security level. For example, the higher the functional complexity, the greater the target coverage; the higher the required security level, the greater the target coverage.

[0055] It should be noted that the check items corresponding to two target use cases in the target use case set can also be repeated, and therefore the first number is the number of all different check items corresponding to the target use case set.

[0056] In some embodiments, the candidate use case set, the check item set, and the first check item corresponding to the candidate use case can be input into a pre-set artificial intelligence model to obtain the target use case set. In this way, the target use case set can be quickly determined, the efficiency of generating test cases is improved, and the verification efficiency is further improved.

[0057] The artificial intelligence model can be obtained by training an artificial intelligence optimization algorithm.

[0058] In some embodiments, the artificial intelligence model can be an evolutionary algorithm model, which is generated according to a genetic algorithm, can also be generated based on an ant colony algorithm, can also be generated based on a particle swarm algorithm, etc. The present disclosure does not limit this.

[0059] In some embodiments, the artificial intelligence model can also be a penalty model. In some embodiments, the penalty model can be generated based on a reinforcement learning penalty mechanism.

[0060] In some embodiments, the artificial intelligence model can also be a reward model, and in some embodiments, the reward model can be generated based on a reinforcement learning reward mechanism.

[0061] In some embodiments, the artificial intelligence model can also be a greedy model, and the greedy algorithm model is generated based on a greedy algorithm.

[0062] In some embodiments, the artificial intelligence model can be generated according to a training data set. The training data set includes a sample candidate use case set, a sample test item set, and a sample target use case set. The training method can be an evolutionary algorithm (such as a genetic algorithm, an ant colony algorithm, a particle swarm algorithm, etc.), a reinforcement learning algorithm (such as a reward mechanism, a punishment mechanism, etc.), or a greedy algorithm. The present disclosure does not limit this.

[0063] In the embodiments of the present disclosure, the candidate use case set and the test item set corresponding to the tested object are determined, then the first test item corresponding to the candidate use case in the candidate use case set is determined, and finally the target use case set with a coverage rate meeting a target coverage rate is determined from the candidate use case set according to the test item set and the first test item corresponding to the candidate use case. Therefore, before verifying the tested object, the target use case set with a coverage rate meeting the demand and a small number of target use cases can be selected from a large number of candidate use cases based on the first test item corresponding to each candidate use case and the preset test item set, so as to avoid case redundancy as much as possible, and thus the verification efficiency can be improved when the target use case set is used to verify the tested object.

[0064] Figure 2 The flowchart of a method for generating test cases provided by an embodiment of the present disclosure is shown in FIG. 1. Figure 2 As shown in FIG. 1, when the artificial intelligence model is an evolutionary algorithm model, the method for generating test cases can include the following steps:

[0065] Step 201: determining a candidate use case set and a test item set corresponding to a tested object.

[0066] Step 202: determining a first test item corresponding to a candidate use case in the candidate use case set, wherein the first test item belongs to the test item set.

[0067] The specific implementation forms of steps 201 and 202 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.

[0068] Step 203: inputting the candidate use case set, the test item set, and the first test item corresponding to the candidate use case into a preset evolutionary algorithm model to obtain a target use case set.

[0069] The coverage rate of the target use case set is greater than or equal to the target coverage rate, the coverage rate of the target use case set is a ratio of a first number to a second number, the first number is a number of all different test items corresponding to the target use case set, and the second number is a number of all test items in the test item set.

[0070] In the embodiments of the present disclosure, the evolutionary algorithm model is a genetic algorithm model. In some embodiments, the candidate use case set, the test item set, and the first test item corresponding to the candidate use case are input into a preset evolutionary algorithm model to obtain the target use case set, including:

[0071] In step 2031, a third number of use case sequences are determined from the candidate use case set.

[0072] The third number can be 10, 100, etc. The present disclosure does not limit this.

[0073] In some embodiments, the number of candidate use cases included in each use case sequence can be the same.

[0074] In some embodiments, the number of candidate use cases in the use case sequence can be determined according to the verification requirement of the test object. For example, if it is set to complete the verification of the test object within a first time length, if the first time length can only complete the verification of 100 use cases, then each use case sequence includes 100 candidate use cases.

[0075] For example, if the value of the third number is 50 and each use case sequence includes 100 candidate use cases, then 5000 candidate use cases can be randomly extracted from the candidate use case set, and then the 5000 candidate use cases are evenly divided into 50 groups, and the 100 candidate use cases in each group are randomly sorted to obtain 50 use case sequences.

[0076] In step 2032, the first coverage rate corresponding to each use case sequence is determined according to the first test item corresponding to each candidate use case and the test item set.

[0077] In some embodiments, the sixth number of all different test items corresponding to all candidate use cases in each use case sequence is determined according to the first test item of each candidate use case, and the ratio of the sixth number to the second number is determined as the first coverage rate corresponding to each use case sequence.

[0078] For example, the use case sequence includes 100 candidate use cases, the sixth number of all different test items corresponding to the 100 candidate use cases is 300, and the second number is 400. Therefore, the first coverage rate is 0.75.

[0079] In step 2033, in the case where the first coverage rate corresponding to at least one use case sequence is greater than or equal to the target coverage rate, the use case sequence with the largest first coverage rate is determined as the target use case set.

[0080] In some embodiments, in the case where the first coverage rate corresponding to each use case sequence is less than the target coverage rate, the following steps can also be performed:

[0081] Step 2034, in the case where the first coverage corresponding to each use case sequence is less than the target coverage, updating a part of use cases in each use case sequence.

[0082] It should be noted that the first coverage corresponding to each use case sequence is less than the target coverage, which means that each use case sequence cannot be used as the target use case set. The use cases in the use case sequence need to be updated to obtain the target use case set.

[0083] In some embodiments, the remaining candidate use cases in the candidate use case set can be used to update a part of use cases in the use case sequence. Among them, the remaining candidate use cases are candidate use cases not contained in the use case sequence.

[0084] In some embodiments, the operation of randomly determining the fourth number of use case sequences from the third number of use case sequences is performed i times; the use case sequence with the largest first coverage in the fourth number of use case sequences determined in the i-th time is determined as the i-th use case sequence; the m-th to m+n-th candidate use cases in the 2q-1-th use case sequence are exchanged with the m-th to m+n-th candidate use cases in the 2q-th use case sequence.

[0085] Among them, the value of i is a positive integer less than or equal to the third number.

[0086] Among them, the value of q is a positive integer less than i / 2.

[0087] Among them, the values of m and n are positive integers. The value of m+n is less than or equal to the total number of candidate use cases in the use case sequence.

[0088] For example, if the third number is 50, the fourth number is 20, the value of i is a natural number from 1 to 30, m is 15, and n is 10, then in the i-th time, 20 use case sequences are selected from 50 use case sequences, and the use case sequence with the largest first coverage in the 20 use case sequences is determined as the i-th use case sequence. Then, the 15th to 25th candidate use cases in the 1st use case sequence are exchanged with the 15th to 25th candidate use cases in the 2nd use case sequence, the 15th to 25th candidate use cases in the 3rd use case sequence are exchanged with the 15th to 25th candidate use cases in the 4th use case sequence, and so on, until the 15th to 25th candidate use cases in the 29th use case sequence are exchanged with the 15th to 25th candidate use cases in the 30th use case sequence.

[0089] It should be noted that the greater the first coverage corresponding to the use case sequence, the lower the repetition rate of the first check item corresponding to the plurality of candidate use cases contained in the use case sequence. Therefore, the candidate use cases in the use case sequence with a greater first coverage are exchanged to quickly obtain the target use case set with a coverage greater than or equal to the target coverage.

[0090] In some embodiments, after sequentially exchanging the mth to (m+n)th candidate use cases in the 2q-1th use case sequence with the mth to (m+n)th use cases in the 2qth use case sequence, a random number can be generated for each candidate use case in each use case sequence. In the case where the random number corresponding to any candidate use case in the use case sequence is greater than a preset probability, any candidate use case is replaced based on any remaining candidate use case in the candidate use case set, wherein the remaining candidate use case is a candidate use case not contained in the use case sequence. Thus, some candidate use cases in the use case sequence can be randomly replaced, so that the target use case set with a coverage greater than or equal to the target coverage can be obtained more quickly.

[0091] The preset probability can be a pre-set value, such as 0.3, 0.5, etc. The present disclosure does not limit this.

[0092] For example, if the preset probability is 0.7 and the random number corresponding to the first candidate use case in the use case sequence is 0.8, the first candidate use case is replaced; if the random number corresponding to the second candidate use case is 0.6, the second candidate use case is not replaced.

[0093] Step 2035, return to perform the operation of determining the first coverage corresponding to each updated use case sequence until the first coverage corresponding to at least one updated use case sequence is greater than or equal to the target coverage.

[0094] For example, after updating a part of the use cases in each use case sequence, the first coverage corresponding to each updated use case sequence is determined. In the case where the first coverage corresponding to each updated use case sequence is less than the target coverage, a part of the use cases in each updated use case sequence is updated until the first coverage corresponding to any updated use case sequence is greater than or equal to the target coverage, and any use case sequence is determined as the target use case set.

[0095] Thus, the evolutionary algorithm model can output the target use case set.

[0096] In the embodiments of the present disclosure, from the candidate use case set, a third number of use case sequences are determined, a first coverage corresponding to each use case sequence is determined according to the first check item corresponding to each candidate use case and the check item set, in the case where the first coverage corresponding to each use case sequence is less than the target coverage, a part of the use cases in each use case sequence is updated, and the operation of determining the first coverage corresponding to each use case sequence is returned until the first coverage corresponding to any use case sequence is greater than or equal to the target coverage, and finally any use case sequence is determined as the target use case set. Therefore, in the case where the first coverage corresponding to each use case sequence is less than the target coverage, a part of the use cases in each use case sequence can be updated, and the evolutionary algorithm is used, so that the target use case set meeting the coverage requirement and having a smaller number of use cases can be quickly found from the candidate use case set, the efficiency of determining the target use case set is improved, and the verification efficiency of the measured object can be further improved.

[0097] Figure 3 A flowchart of a method for generating test cases provided by an embodiment of the present disclosure is shown in FIG. 1. Figure 3 As shown in FIG. 1, in the case where the artificial intelligence model is a reward model, the method for generating test cases can include the following steps:

[0098] Step 301, determining a candidate use case set corresponding to a measured object and a check item set.

[0099] Step 302, determining a first check item corresponding to a candidate use case in the candidate use case set, wherein the first check item belongs to the check item set.

[0100] The specific implementation forms of steps 301 and 302 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.

[0101] Step 303, inputting the candidate use case set, the check item set, and the first check item corresponding to the candidate use case into a preset reward model to obtain a target use case set.

[0102] The coverage corresponding to the target use case set is greater than or equal to a target coverage, the coverage corresponding to the target use case set is a ratio of a first number to a second number, the first number is a number of all different check items corresponding to the target use case set, and the second number is a number of all check items in the check item set.

[0103] In some embodiments, inputting the candidate use case set, the check item set, and the first check item corresponding to the candidate use case into the preset reward model to obtain the target use case set includes:

[0104] Step 3031, determine the union set between each candidate use case and the initial use case set, wherein the initial state of the initial use case set is an empty set.

[0105] It should be noted that in the case of the initial use case set being an empty set, the union set of each candidate use case and the initial use case set is each candidate use case.

[0106] Step 3032, determine the second coverage corresponding to each union set according to the first check item corresponding to the candidate use case in each union set and the check item set.

[0107] In some embodiments, the seventh number of all different check items corresponding to the union set can be determined according to the first check item corresponding to each candidate use case in the union set, and the ratio of the seventh number to the second number is determined as the second coverage corresponding to the union set.

[0108] It should be noted that in the case of the initial use case set being an empty set, the second coverage corresponding to each union set is the coverage corresponding to each candidate use case. That is, the ratio of the number corresponding to the first check item to the second number.

[0109] Step 3033, in the case that the maximum second coverage is greater than or equal to the target coverage, the union set corresponding to the maximum second coverage is determined as the target use case set.

[0110] In some embodiments, in the case that the maximum second coverage is less than the target coverage, the following steps can also be performed:

[0111] Step 3034, in the case that the maximum second coverage is less than the target coverage, the candidate use case corresponding to the union set of the maximum second coverage is added to the initial use case set, and is deleted from the candidate use case set.

[0112] It should be noted that adding the candidate use case corresponding to the union set with the maximum second coverage to the initial use case set can obtain an initial use case set with the same number of use cases but the maximum coverage.

[0113] Step 3035, return to perform the operation of determining the union set between each candidate use case in the candidate use case set and the initial use case set until the maximum second coverage is greater than or equal to the target coverage.

[0114] In some embodiments, the initial use case set can also be determined as the target use case set in the case that the initial use case set contains a preset number of use cases. Thus, the coverage of the determined preset number of use cases can also be maximized in the case of limiting the number of use cases.

[0115] For example, if the candidate use case set contains 1000 candidate use cases, first, the coverage of each candidate use case in the 1000 candidate use cases is calculated respectively, a candidate use case with the maximum coverage is added to the initial use case set (at this time, the initial use case set contains 1 use case), and is deleted from the candidate use case set (at this time, the candidate use case set contains 999 candidate use cases), then the union of each candidate use case in the 999 candidate use cases in the candidate use case set and the initial use case set is determined, and the second coverage of each union is calculated, a candidate use case corresponding to the union with the maximum second coverage is added to the initial use case set (at this time, the initial use case set contains 2 use cases), and is deleted from the candidate use case set (at this time, the candidate use case set contains 998 candidate use cases), until the coverage of the initial use case set is greater than or equal to the target coverage, or the initial use case set contains a preset number of use cases.

[0116] Therefore, a preset reward model can be used to output the target use case set.

[0117] In the embodiments of the present disclosure, the union of each candidate use case in the candidate use case set and the initial use case set is determined respectively, then the second coverage of each union is determined according to the first check item corresponding to each candidate use case in the union and the check item set, and then the candidate use case corresponding to the union with the maximum second coverage is added to the initial use case set and is deleted from the candidate use case set, and the operation of determining the union is returned to be performed until the coverage of the initial use case set is greater than or equal to the target coverage, and finally the initial use case set is determined as the target use case set. Therefore, each time a candidate use case that has a greater impact on the coverage of the initial use case set is selected from the candidate use case set and is added to the initial use case set, the reinforcement learning reward mechanism is used, so that the target use case set that meets the coverage requirement and has a smaller number of use cases can be quickly found from the candidate use case set, the efficiency of determining the target use case set is improved, and then the verification efficiency of the measured object can be further improved.

[0118] Figure 4 A flowchart of a method for generating test cases provided by an embodiment of the present disclosure is shown in FIG. 1, in the case of a punishment model of a reinforcement learning model. The method for generating test cases can include the following steps: Figure 4

[0119] Step 401, determine the check item set corresponding to the candidate use case set of the measured object.

[0120] Step 402, determine the first check item corresponding to the candidate use case in the candidate use case set, wherein the first check item belongs to the check item set.

[0121] ​The specific implementation forms of steps 401 and 402 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be described in detail here.

[0122] Step 403: inputting the candidate use case set, the test item set, and the first test item corresponding to the candidate use case into a preset penalty model to obtain a target use case set.

[0123] The coverage rate corresponding to the target use case set is greater than or equal to the target coverage rate, and the coverage rate corresponding to the target use case set is a ratio of a first number to a second number, the first number is a number of all different test items corresponding to the target use case set, and the second number is a number of all test items in the test item set.

[0124] In some embodiments, inputting the candidate use case set, the test item set, and the first test item corresponding to the candidate use case into a preset penalty model to obtain a target use case set includes:

[0125] Step 4031: determining a complement between each candidate use case in the candidate use case set and the candidate use case set.

[0126] Step 4032: determining a third coverage rate corresponding to each complement according to the first test item corresponding to the candidate use case in each complement and the test item set.

[0127] In some embodiments, the eighth number of all different test items corresponding to the complement can be determined according to the first test item corresponding to each candidate use case in the complement, and the third coverage rate corresponding to the complement is determined as a ratio of the first number to the second number.

[0128] Step 4033: in a case where the maximum third coverage rate is less than the target coverage rate, determining the candidate use case set as the target use case set.

[0129] Step 4034: in a case where the maximum third coverage rate is greater than or equal to the target coverage rate, deleting the candidate use case corresponding to the complement of the maximum third coverage rate from the candidate use case set.

[0130] It should be noted that in a case where the maximum third coverage rate is greater than or equal to the target coverage rate, it indicates that there may still be test item redundancy in the candidate use case set, and the candidate use case corresponding to the complement with the maximum third coverage rate has the minimum impact on the coverage rate of the candidate use case set. In order to further reduce the number of use cases for verifying the measured object, the candidate use case corresponding to the complement with the maximum third coverage rate can be deleted from the candidate use case set.

[0131] Step 4035: returning to perform the operation of determining the complement between each candidate use case in the candidate use case set and the candidate use case set until the maximum third coverage rate is less than the target coverage rate.

[0132] In some embodiments, the candidate use case set can also be determined as the target use case set in the case that the candidate use case set contains a preset number of use cases. Thus, the coverage of the determined preset number of use cases can also be maximized in the case that the number of use cases is limited.

[0133] For example, if the candidate use case set contains 1000 candidate use cases, each candidate use case in the 1000 candidate use cases is first calculated with the complement of the candidate use case set, then the third coverage corresponding to each complement is calculated, and the complement with the largest third coverage is deleted from the candidate use case set (at this time, the candidate use case set contains 999 candidate use cases), then each candidate use case in the 999 candidate use cases in the candidate use case set is determined with the complement of the candidate use case set, and the third coverage corresponding to each complement is calculated, the candidate use case corresponding to the complement with the largest third coverage is deleted from the candidate use case set (at this time, the candidate use case set contains 998 candidate use cases), and the process is repeated until the coverage corresponding to the candidate use case set is greater than or equal to the target coverage, or the candidate use case set contains a preset number of use cases.

[0134] Thus, the target use case set output by the preset penalty model can be obtained.

[0135] In the embodiments of the present disclosure, the complement between each candidate use case in the candidate use case set and the candidate use case set is determined respectively; the third coverage corresponding to each complement is determined according to the first check item corresponding to each candidate use case in the complement and the check item set; in the case that the largest third coverage is greater than or equal to the target coverage, the candidate use case corresponding to the complement with the largest third coverage is deleted from the candidate use case set; the operation of determining the complement is returned to execute until the largest third coverage is less than the target coverage, and the candidate use case set corresponding to the complement with the largest third coverage is determined as the target use case set. Thus, each time a candidate use case with the smallest impact on the coverage of the candidate use case set is deleted from the candidate use case set, the reinforcement learning penalty mechanism is used, so that the target use case set that meets the coverage requirement and has a smaller number of use cases can be quickly found from the candidate use case set, the efficiency of determining the target use case set is improved, and the verification efficiency of the measured object can be further improved.

[0136] Figure 5 The flowchart of the method for generating test cases provided by an embodiment of the present disclosure is shown in the case that the artificial intelligence model is a greedy algorithm model, as shown in Figure 5 The method for generating test cases can include the following steps:

[0137] Step 501, determine the check item set corresponding to the candidate use case set of the measured object.

[0138] Step 502, determining a first check item corresponding to each candidate use case in the candidate use case set, wherein the first check item belongs to the check item set.

[0139] The specific implementation forms of steps 501 and 502 can refer to the detailed descriptions in other embodiments of the present disclosure, and will not be repeated here.

[0140] Step 503, inputting the candidate use case set, the check item set, and the first check item corresponding to the candidate use case into a preset greedy algorithm model to obtain a target use case set.

[0141] The coverage rate corresponding to the target use case set is greater than or equal to the target coverage rate, the coverage rate corresponding to the target use case set is a ratio of a first number to a second number, the first number is a number of all different check items corresponding to the target use case set, and the second number is a number of all check items in the check item set.

[0142] In some embodiments, inputting the candidate use case set, the check item set, and the first check item corresponding to the candidate use case into the preset greedy algorithm model to obtain the target use case set comprises:

[0143] Step 5031, generating a first vector corresponding to each candidate use case according to the first check item corresponding to each candidate use case and the check item set.

[0144] In some embodiments, the check item sequence corresponding to the check item set is determined, and in a case where the first check item corresponding to the candidate use case is the same as the jth element in the check item sequence, the jth element in the first vector is determined as a first value, and the remaining elements are determined as a second value.

[0145] In some embodiments, the check item sequence can be obtained by arranging the check items in the check item set in any order.

[0146] In some embodiments, the first value can be 1, and the second value can be 0. The present disclosure does not make any limitation in this regard.

[0147] For example, the check item sequence is [check item 1, check item 2, check item 3, check item 4, check item 5], and if the first check item corresponding to the candidate use case is check item 2 and check item 4, then the first vector corresponding to the candidate use case is [0, 1, 0, 1, 0].

[0148] Step 5032, determining a first distance between each two first vectors.

[0149] In some embodiments, a distance calculation formula can be employed to calculate the first distance between two first vectors. In some embodiments, the distance calculation formula can be a Euclidean distance calculation formula, a Manhattan distance formula, etc. The present disclosure does not limit this.

[0150] Step 5033, the candidate use cases corresponding to the two first vectors with the largest first distance are added to the initial use case set.

[0151] It should be noted that the larger the first distance between the two first vectors, the greater the coverage of the two candidate use cases. In order to make the target use case set have the least number of use cases while meeting the coverage requirement, the candidate use cases corresponding to the two first vectors with the largest distance can be added to the initial use case set.

[0152] It should be noted that the larger the first distance between the two first vectors, the greater the coverage of the two candidate use cases. In order to make the target use case set have the least number of use cases while meeting the coverage requirement, the candidate use cases corresponding to the two first vectors with the largest distance can be added to the initial use case set.

[0153] Step 5034, the fourth coverage corresponding to the initial use case set is determined according to the first check items corresponding to the candidate use cases in the initial use case set and the check item set.

[0154] In some embodiments, the eighth number of all different check items corresponding to the initial use case set is determined according to the first check items corresponding to the candidate use cases, and the fourth coverage is determined as the ratio of the eighth number to the second number.

[0155] Step 5035, in the case where the fourth coverage is greater than or equal to the target coverage, the initial use case set is determined as the target use case set.

[0156] In some embodiments, in the case where the fourth coverage is less than the target coverage, the following steps are further included:

[0157] Step 5036, in the case where the fourth coverage is less than the target coverage, the candidate use cases corresponding to the two first vectors with the largest first distance are deleted from the candidate use case set.

[0158] Step 5037, the second distance between the first vector corresponding to each candidate use case in the candidate use case set and the first vector corresponding to each candidate use case in the initial use case set is determined.

[0159] It should be noted that for any candidate use case in the candidate use case set, the second distance between the candidate use case and each candidate use case in the initial use case set needs to be calculated.

[0160] Step 5038, the candidate use case corresponding to the largest second distance in the candidate use case set is deleted from the candidate use case set and added to the initial use case set.

[0161] It should be noted that the greater the first distance, the greater the coverage rate of the initial case set after adding the corresponding candidate case to the initial case set. Therefore, adding the candidate case corresponding to the maximum first distance in the candidate case set to the initial case set can maximize the coverage rate of the determined initial case set under the same use case amount.

[0162] In step 5039, the operation of determining the second distance is returned to be performed until the fourth coverage rate corresponding to the initial case set is greater than or equal to the target coverage rate.

[0163] In some embodiments, the initial case set can also be determined as the target case set in the case of containing a preset number of cases in the initial case set. Thus, the coverage rate of the determined preset number of cases can also be maximized under the limitation of the number of cases.

[0164] For example, if the candidate case set contains 1000 candidate cases, first calculate the distance between each two candidate cases corresponding to the first vector, and add the candidate cases corresponding to the two first vectors with the maximum distance to the initial case set (at this time, the initial case set contains 2 cases), and delete from the candidate case set (at this time, the candidate case set contains 998 candidate cases).

[0165] Then, determine the first distance between the first vector corresponding to each candidate case in the 998 candidate cases and the first vector corresponding to each case in the initial case set, and add the candidate case with the maximum first distance in the 998 candidate cases to the initial case set (at this time, the initial case set contains 3 cases), and delete from the candidate case set (at this time, the candidate case set contains 997 candidate cases).

[0166] Then, determine the first distance between the first vector corresponding to each candidate case in the 997 candidate cases and the first vector corresponding to each case in the initial case set, and add the candidate case with the maximum first distance in the 997 candidate cases to the initial case set (at this time, the initial case set contains 4 cases), and delete from the candidate case set (at this time, the candidate case set contains 996 candidate cases).

[0167] In turn, until the coverage rate corresponding to the initial case set is greater than or equal to the target coverage rate, and the initial case set is determined as the target case set.

[0168] Thus, the target case set output by the preset greedy algorithm model can be obtained.

[0169] In the embodiments of the present disclosure, a first vector corresponding to each candidate use case is generated according to a first check item corresponding to each candidate use case and the check item set; candidate use cases corresponding to two first vectors with the largest distance are added to the initial use case set and deleted from the candidate use case set; a first distance between the first vector corresponding to each candidate use case in the candidate use case set and the first vector corresponding to each candidate use case in the initial use case set is determined; a candidate use case corresponding to the largest first distance in the candidate use case set is deleted from the candidate use case set and added to the initial use case set; the operation of determining the first distance is returned until the fourth coverage rate corresponding to the initial use case set is greater than or equal to the target coverage rate, and the initial use case set is determined as the target use case set. Therefore, the target use case can be selected from the candidate use case set according to the difference between each candidate use case in the candidate use case set and each use case in the initial use case set, so that the target use case set meeting the coverage requirement and having a small number of use cases can be quickly found from the candidate use case set, the efficiency of determining the target use case set is improved, and the verification efficiency of the measured object can be further improved.

[0170] To achieve the above-mentioned embodiments, the present disclosure further provides a device for generating test cases.

[0171] Figure 6 A structural schematic diagram of the device for generating test cases provided by the embodiments of the present disclosure is shown.

[0172] As shown in Figure 6 the device 600 for generating test cases can include:

[0173] A first determination module 601 is configured to determine a candidate use case set corresponding to a measured object and a check item set.

[0174] A second determination module 602 is configured to determine a first check item corresponding to a candidate use case in the candidate use case set, wherein the first check item belongs to the check item set.

[0175] A third determination module 603 is configured to determine a target use case set corresponding to the measured object from the candidate use case set according to the check item set and the first check item corresponding to the candidate use case, wherein the coverage rate of the target use case set meets a target coverage rate.

[0176] In some embodiments, the third determination module 603 is configured to:

[0177] input the candidate use case set, the check item set, and the first check item corresponding to the candidate use case into a preset artificial intelligence model to obtain the target use case set.

[0178] In some embodiments, the artificial intelligence model is an evolutionary algorithm model, and the third determination module 603 is further configured to:

[0179] From the candidate use case set, a third number of use case sequences are determined;

[0180] According to the first inspection item corresponding to each candidate use case and the inspection item set, the first coverage rate corresponding to each use case sequence is determined;

[0181] In the case where the first coverage rate corresponding to at least one use case sequence is greater than or equal to the target coverage rate, the use case sequence with the largest first coverage rate is determined as the target use case set.

[0182] In some embodiments, the third determination module 603 is configured to:

[0183] In the case where the first coverage rate corresponding to each use case sequence is less than the target coverage rate, a part of the use cases in each use case sequence is updated;

[0184] Return to perform the operation of determining the first coverage rate corresponding to each updated use case sequence until the first coverage rate corresponding to at least one updated use case sequence is greater than or equal to the target coverage rate.

[0185] In some embodiments, the third determination module 603 is configured to:

[0186] Performing i times, randomly determining a fourth number of use case sequences from the third number of use case sequences, wherein i is a positive integer less than or equal to the third number;

[0187] The use case sequence with the largest first coverage rate in the fourth number of use case sequences determined in the i-th time is determined as the i-th use case sequence;

[0188] The m-th to m+n-th candidate use cases in the 2q-1-th use case sequence are sequentially exchanged with the m-th to m+n-th candidate use cases in the 2q-th use case sequence, wherein q is a positive integer less than i / 2, m and n are positive integers, and m+n is less than or equal to the total number of candidate use cases in the use case sequence.

[0189] In some embodiments, the third determination module 603 is configured to:

[0190] For each candidate use case in each use case sequence, a random number is generated;

[0191] In the case where the random number corresponding to any candidate use case in the use case sequence is greater than a preset probability, any candidate use case is replaced based on any remaining candidate use case in the candidate use case set, wherein the remaining candidate use case is a candidate use case not contained in the use case sequence.

[0192] In some embodiments, the artificial intelligence model is a reward model, and the third determining module 603 is configured to:

[0193] determine a union set between each candidate use case and the initial use case set, wherein an initial state of the initial use case set is an empty set;

[0194] determine a second coverage corresponding to each union set according to the first check item corresponding to the candidate use case in the union set and the check item set;

[0195] in a case where the maximum second coverage is greater than or equal to the target coverage, determine the union set corresponding to the maximum second coverage as the target use case set.

[0196] In some embodiments, the third determining module 603 is configured to:

[0197] in a case where the maximum second coverage is less than the target coverage, add the candidate use case corresponding to the union set of the maximum second coverage to the initial use case set and delete the candidate use case from the candidate use case set;

[0198] return to perform the operation of determining the union set between each candidate use case in the candidate use case set and the initial use case set until the maximum second coverage is greater than or equal to the target coverage.

[0199] In some embodiments, the artificial intelligence model is a penalty model, and the third determining module 603 is configured to:

[0200] determine a complement set between each candidate use case in the candidate use case set and the candidate use case set;

[0201] determine a third coverage corresponding to each complement set according to the first check item corresponding to the candidate use case in the complement set and the check item set;

[0202] in a case where the maximum third coverage is less than the target coverage, determine the candidate use case set as the target use case set.

[0203] In some embodiments, the third determining module 603 is configured to:

[0204] in a case where the maximum third coverage is greater than or equal to the target coverage, delete the candidate use case corresponding to the complement set of the maximum third coverage from the candidate use case set;

[0205] return to perform the operation of determining the complement set between each candidate use case in the candidate use case set and the candidate use case set until the maximum third coverage is less than the target coverage.

[0206] In some embodiments, the artificial intelligence model is a greedy algorithm model, and the third determining module 603 is configured to:

[0207] generate a first vector corresponding to each candidate use case according to the first check item corresponding to each candidate use case and the check item set;

[0208] determine a first distance between each two first vectors;

[0209] add the candidate use cases corresponding to the two first vectors with the largest first distance to the initial use case set respectively;

[0210] determine a fourth coverage corresponding to the initial use case set according to the first check item corresponding to each candidate use case in the initial use case set and the check item set;

[0211] determine the initial use case set as the target use case set in a case where the fourth coverage is greater than or equal to the target coverage.

[0212] In some embodiments, the third determination module 603 is configured to:

[0213] remove the candidate use cases corresponding to the two first vectors with the largest first distance from the candidate use case set in a case where the fourth coverage is less than the target coverage;

[0214] determine a second distance between the first vector corresponding to each candidate use case in the candidate use case set and the first vector corresponding to each candidate use case in the initial use case set;

[0215] remove the candidate use case corresponding to the largest second distance from the candidate use case set and add it to the initial use case set;

[0216] return to perform the operation of determining the second distance until the fourth coverage corresponding to the initial use case set is greater than or equal to the target coverage.

[0217] In some embodiments, the third determination module 603 is configured to:

[0218] determine a check item sequence corresponding to the check item set;

[0219] determine the jth element in the first vector as the first value and the rest of the elements as the second value in a case where the first check item corresponding to the candidate use case is the same as the jth element in the check item sequence, where j is a positive integer.

[0220] The functions and specific implementation principles of the above modules in the embodiments of the present disclosure can be referred to the above method embodiments, which will not be described here.

[0221] The device for generating test cases provided in the embodiments of the present disclosure first determines a candidate case set and an inspection item set corresponding to the to-be-tested object, then determines a first inspection item corresponding to a candidate case in the candidate case set, and finally determines a target case set satisfying a target coverage rate from the candidate case set according to the inspection item set and the first inspection item corresponding to the candidate case. In this way, before the to-be-tested object is verified, the target case set satisfying the demand in coverage rate and having a small quantity can be screened from a large number of candidate cases based on the first inspection item corresponding to each candidate case and the preset inspection item set, so that case redundancy can be avoided as much as possible, and the verification efficiency can be improved when the to-be-tested object is verified by using the target case set.

[0222] The present disclosure also provides a chip, which is obtained by verifying the target case set.

[0223] Figure 7 FIG. 1 is a structural schematic diagram of a chip provided in the embodiments of the present disclosure. For example, the chip can be the chip 700 shown in FIG. 7, but the present disclosure is not limited thereto. Figure 7

[0224] The chip 700 includes a processing circuit 701 and one or more interface circuits 702. Optionally, the interface circuit 702 is connected with a memory 703. The interface circuit 702 can be configured to receive a signal from the memory 703 or other devices, and the interface circuit 702 can be configured to send a signal to the memory 703 or other devices. For example, the interface circuit 702 can read an instruction stored in the memory 703 and send the instruction to the processing circuit 701.

[0225] In some embodiments, the terms of interface circuit, interface, transceiver pin, and transceiver can be replaced with each other.

[0226] In some embodiments, the chip 700 further includes one or more memories 703 for storing instructions. Optionally, all or part of the memory 703 can be outside the chip 700.

[0227] The present disclosure also provides a terminal including the chip obtained by verifying the target case set.

[0228] In some embodiments, the terminal can be a mobile phone, a computer, a tablet, an electronic watch, or the like. The present disclosure does not limit the terminal.

[0229] In order to implement the above-mentioned embodiments, the present disclosure also provides an electronic device including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the method for generating test cases provided in the foregoing embodiments of the present disclosure is implemented.

[0230] Figure 8 ​A block diagram illustrating an exemplary electronic device suitable for use in implementing an embodiment of the present disclosure is shown. Figure 8 The electronic device 12 shown is merely one example. It should be appreciated that the functions and uses of embodiments of the present disclosure are not limited to the electronic device 12 shown.

[0231] As shown, the electronic device 12 is in the form of a general- purpose computing device. The components of the electronic device 12 can include, but are not limited to, one or more processors or processing units 16, a system memory 28, and a bus 18 that couples various system components including the system memory 28 to the processing unit 16. Figure 8 The bus 18 represents one or more of any of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration bus (e.g., an Accelerated Graphics Port, or AGP bus) and a processor or local bus using any of a variety of bus architectures. By way of example, these bus architectures include Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.

[0232] The electronic device 12 typically includes a variety of computer system readable media. Such media can be any available media that is accessible by the electronic device 12 and includes both volatile and non- volatile media, removable and non-removable media.

[0233] The memory 28 can include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 can further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 34 can be provided for reading from and writing to non-removable, non-volatile magnetic media (e.g., a "hard drive").

[0234] Although not shown, a common interpretation of the storage system 34 would be a magnetic hard disk drive (also known as a "hard drive"). Although not specifically shown, alternative types of storage media, which can be used with the electronic device 12, include semiconductor-based memory devices. These devices include, but are not limited to, storage class memory devices, RAM, ROM, programmable read only memory (PROM), erasable programmable read only memory (EPROM), electrically erasable programmable read only memory (EEPROM), flash memory, solid state drives (SSDs), and other types of semiconductor-based memory. Figure 8 Figure 8 ​A disk drive, a floppy disk drive, a CD-ROM drive, a DVD-ROM drive, or other removable media drive, can be provided for reading from and writing to a removable n onvolatile magnetic disk (e.g., a "floppy disk"), and to a removable nonvolatile optical disk (e.g., a CD ROM, a DVD ROM, or another optical medium). In such instances, each drive can be connected to the bus 18 by one or more data media interfaces. The memory 28 can include at least one program product having a set (e.g., at least one) of program modules that are configured to carry out the functions of embodiments of the disclosure.

[0235] Program / utility 40, having a set (at least one) of program modules 42, can be stored in memory 28 by way of example, and not limitation, as well as an operating system, one or more application programs, other program modules, and program data, each or some combination thereof, can include implementation of a networking environment. Program modules 42 generally carry out the functions and / or methodologies of embodiments of the disclosure as described herein.

[0236] The electronic device 12 can also communicate with one or more external devices 14 such as a keyboard or a pointing device, displays 24, etc.; other devices such as devices that enable a user to interact with the electronic device 12; and / or any devices (e.g., network card, modem, etc.) that enable the electronic device 12 to communicate with one or more other computing devices. Such communication can occur via the input / output (I / O) interface(s) 22. Still yet, the electronic device 12 can communicate with one or more networks, such as one or more local area networks (LANs), wide area networks (WANs), and / or the Internet, through a network adapter 20. As depicted, the network adapter 20 communicates with the other components of the electronic device 12 via the bus 18. It should be appreciated that the network adapter 20 and / or the one or more components of the electronic device 12 can be collectively provided as a means for performing some or all of the functions recited in the above-described embodiments.

[0237] The processing unit(s) 16 can perform functions and data processing by executing programs stored in the system memory 28, such as to implement the methods described in the above embodiments.

[0238] To achieve the above-mentioned embodiments, the present disclosure further provides a computer readable storage medium storing a computer program, the computer program being executed by a processor to implement the method for generating test cases according to the above-mentioned embodiments of the present disclosure.

[0239] To achieve the above-mentioned embodiments, the present disclosure further provides a computer program product comprising a computer program, the computer program being executed by a processor to implement the method for generating test cases according to the above-mentioned embodiments of the present disclosure.

[0240] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in the present disclosure comply with relevant laws and regulations and do not violate public order and good customs.

[0241] In the description of the present specification, the description referring to the terms "one embodiment", "some embodiments", "an example", "a specific example", or "some examples" and the like means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present disclosure. In the present specification, the illustrative description of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any appropriate manner in any one or more embodiments or examples. In addition, the person skilled in the art can combine and combine the different embodiments or examples described in the present specification and the features of the different embodiments or examples, without contradiction.

[0242] In addition, the terms "first", "second" are only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined with "first", "second" can explicitly or implicitly include at least one of the features. In the description of the present disclosure, the meaning of "a plurality of" is at least two, for example, two, three, etc., unless otherwise explicitly specified.

[0243] Any process or method descriptions in flow charts or otherwise described herein can be understood as representing code modules, segments, or portions of code that include one or more executable instructions for implementing the specified logic functions or processes, and the various embodiments of the present disclosure include additional implementation involving other processes or methods. It should be understood that the order of the steps in the process or method described in the flow charts or otherwise described herein is not mandatory and that the steps can be performed in different order, including substantially simultaneously or in reverse order, depending upon the implementation, unless otherwise specifically noted.

[0244] The logic and / or steps represented in the flowcharts and / or described herein, for example, can be considered as a sequence of instructions to implement logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, apparatus, or device, such as a computer-based system, processor- based system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For purposes of this specification, a "computer-readable medium" can be any apparatus that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. The computer-readable medium can be a computer- readable storage medium or a computer-readable signal medium. The computer-readable storage medium can be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer-readable storage medium include the following: an electrical connection having one or more wires (electrical connections), a portable computer diskette (a magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, and a portable compact disc read-only memory (CDROM). In addition, the computer-readable medium can even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, for example, via optical scanning of the paper or other medium, then compiled, interpreted, or otherwise processed in a suitable manner, if necessary, and stored in a computer memory.

[0245] It should be understood that various aspects of the disclosure can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, various steps or methods can be implemented in software or firmware that is stored in memory and executed by a suitable instruction execution system. As such, if desired, the various steps or methods can be implemented in hardware, as in another embodiment, using any or a combination of the following technologies, which are all well-known in the art: a discrete logic circuit(s) having logic gates for implementing logic functions upon an application of data signals, an application specific integrated circuit having appropriate combinational logic gates, a programmable gate array(s) (PGA), a field programmable gate array (FPGA), etc.

[0246] Those of skill in the art would understand that the various embodiments described above can be carried out by a program that instructs related hardware to complete all or part of the steps carried out by the above-described embodiments. The program can be stored in a computer-readable storage medium, and when executed, includes one or a combination of the steps of the method embodiments.

[0247] In addition, each functional unit in each embodiment of the present disclosure can be integrated in one processing module, or each unit can exist physically separately, or two or more units can be integrated in one module. The integrated module can be realized in the form of hardware or in the form of a software functional module. When the integrated module is realized in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer readable storage medium.

[0248] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present disclosure have been shown and described above, it should be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure, and those skilled in the art can make changes, modifications, replacements and variations to the above embodiments within the scope of the present disclosure.

Claims

1. A method of generating test cases, characterized by, The method comprises: determining a candidate test case set and a test item set corresponding to the measured object; determining a first test item corresponding to a candidate test case in the candidate test case set, wherein the first test item belongs to the test item set; determining a target test case set corresponding to the measured object from the candidate test case set according to the test item set and the first test item corresponding to the candidate test case, wherein the coverage rate of the target test case set meets a target coverage rate, and the coverage rate of the target test case set is a ratio of a first quantity to a second quantity, the first quantity being a quantity of all different test items corresponding to the target test case set, and the second quantity being a quantity of all test items in the test item set.

2. The method of claim 1, wherein, The determining of the target test case set from the candidate test case set according to the test item set and the first test item corresponding to the candidate test case comprises: inputting the candidate test case set, the test item set, and the first test item corresponding to the candidate test case into a preset artificial intelligence model to obtain the target test case set.

3. The method of claim 2, wherein, The artificial intelligence model is an evolutionary algorithm model, and inputting the candidate test case set, the test item set, and the first test item corresponding to the candidate test case into the preset evolutionary algorithm model to obtain the target test case set comprises: determining a third quantity of test case sequences from the candidate test case set; determining a first coverage rate corresponding to each test case sequence according to the first test item corresponding to each candidate test case and the test item set; in a case where the first coverage rate corresponding to at least one test case sequence is greater than or equal to the target coverage rate, determining a test case sequence with the maximum first coverage rate as the target test case set.

4. The method of claim 3, wherein, After the determining of the first coverage rate corresponding to each test case sequence according to the first test item corresponding to each candidate test case and the test item set, the method further comprises: in a case where the first coverage rate corresponding to each test case sequence is less than the target coverage rate, updating a part of test cases in each test case sequence; returning to the operation of determining the first coverage rate corresponding to each updated test case sequence until the first coverage rate corresponding to at least one updated test case sequence is greater than or equal to the target coverage rate.

5. The method of claim 3, wherein, The updating of the part of test cases in each test case sequence comprises: performing i times of operations of randomly determining a fourth quantity of test case sequences from the third quantity of test case sequences, wherein i is a positive integer less than or equal to the third quantity; determining a test case sequence with the maximum first coverage rate from the fourth quantity of test case sequences determined in the i th time as an i th test case sequence; sequentially exchanging m th to (m+n) th candidate test cases in a 2q-1 th test case sequence with m th to (m+n) th candidate test cases in a 2q th test case sequence, wherein q is a positive integer less than i / 2, m and n are positive integers, and m+n is less than or equal to a total quantity of candidate test cases in the test case sequence.

6. The method of claim 5, wherein, After the mth to the m+nth candidate use case in the 2q-1th use case sequence is exchanged with the mth to the m+nth candidate use case in the 2qth use case sequence in sequence, the method further comprises: generating a random number for each candidate use case in each of the use case sequences; in a case where the random number corresponding to any candidate use case in the use case sequence is greater than a preset probability, replacing the candidate use case based on any remaining candidate use case in the candidate use case set, wherein the remaining candidate use case is a candidate use case not contained in the use case sequence.

7. The method of claim 2, wherein, The artificial intelligence model is a reward model, and the candidate use case set, the check item set, and the first check item corresponding to the candidate use case are input into a preset reward model to obtain the target use case set, comprising: determining the union set between each candidate use case and an initial use case set, wherein the initial state of the initial use case set is an empty set; determining the second coverage rate corresponding to each of the union sets according to the first check item corresponding to the candidate use case in each of the union sets and the check item set; in a case where the maximum second coverage rate is greater than or equal to the target coverage rate, determining the union set corresponding to the maximum second coverage rate as the target use case set.

8. The method of claim 7, wherein, After the second coverage rate corresponding to each of the union sets is determined according to the first check item corresponding to the candidate use case in each of the union sets and the check item set, the method further comprises: in a case where the maximum second coverage rate is less than the target coverage rate, adding the candidate use case corresponding to the union set of the maximum second coverage rate to the initial use case set and deleting it from the candidate use case set; returning to perform the operation of determining the union set between each candidate use case in the candidate use case set and the initial use case set until the maximum second coverage rate is greater than or equal to the target coverage rate.

9. The method of claim 2, wherein, The artificial intelligence model is a reward model, and the candidate use case set, the check item set, and the first check item corresponding to the candidate use case are input into a preset reward model to obtain the target use case set, comprising: determining the complement set between each candidate use case in the candidate use case set and the candidate use case set; determining the third coverage rate corresponding to each of the complement sets according to the first check item corresponding to the candidate use case in each of the complement sets and the check item set; in a case where the maximum third coverage rate is less than the target coverage rate, determining the candidate use case set as the target use case set.

10. The method of claim 9, wherein, After the third coverage rate corresponding to each of the complement sets is determined according to the first check item corresponding to the candidate use case in each of the complement sets and the check item set, the method further comprises: in a case where the maximum third coverage rate is greater than or equal to the target coverage rate, deleting the candidate use case corresponding to the complement set of the maximum third coverage rate from the candidate use case set; returning to perform the operation of determining the complement set between each candidate use case in the candidate use case set and the candidate use case set until the maximum third coverage rate is less than the target coverage rate.

11. The method of claim 2, wherein, The artificial intelligence model is a greedy algorithm model, and the candidate test case set, the test item set, and the first test item corresponding to the candidate test case are input into a preset greedy algorithm model to obtain the target test case set, including: A first vector corresponding to each candidate test case is generated according to the first test item corresponding to each candidate test case and the test item set; A first distance between each two first vectors is determined; The candidate test cases corresponding to the two first vectors with the largest first distance are added to an initial test case set; A fourth coverage rate corresponding to the initial test case set is determined according to the first test item corresponding to the candidate test case in the initial test case set and the test item set; In a case where the fourth coverage rate is greater than or equal to the target coverage rate, the initial test case set is determined as the target test case set.

12. The method of claim 11, wherein, After the fourth coverage rate corresponding to the initial test case set is determined according to the first test item corresponding to the candidate test case in the initial test case set and the test item set, the method further includes: In a case where the fourth coverage rate is less than the target coverage rate, the candidate test cases corresponding to the two first vectors with the largest first distance are deleted from the candidate test case set; A second distance between the first vector corresponding to each candidate test case in the candidate test case set and the first vector corresponding to each candidate test case in the initial test case set is determined; The candidate test case corresponding to the largest second distance in the candidate test case set is deleted from the candidate test case set and added to the initial test case set; The operation of determining the second distance is returned to be performed until the fourth coverage rate corresponding to the initial test case set is greater than or equal to the target coverage rate.

13. The method of claim 11, wherein, The first vector corresponding to each candidate test case is generated according to the first test item corresponding to each candidate test case and the test item set, including: A test item sequence corresponding to the test item set is determined; In a case where the first test item corresponding to the candidate test case is the same as the jth element in the test item sequence, the jth element in the first vector is determined as a first value, and the remaining elements are determined as a second value, where j is a positive integer.

14. An apparatus for generating test cases, the apparatus comprising: The device includes: A first determination module configured to determine a candidate test case set and a test item set corresponding to a measured object; A second determination module configured to determine a first test item corresponding to a candidate test case in the candidate test case set, wherein the first test item belongs to the test item set; A third determination module configured to determine a target test case set corresponding to the measured object from the candidate test case set according to the test item set and the first test item corresponding to the candidate test case, wherein a coverage rate corresponding to the target test case set satisfies a target coverage rate; wherein the coverage rate corresponding to the target test case set is a ratio of a first number to a second number, the first number is a number of all different test items corresponding to the target test case set, and the second number is a number of all test items in the test item set.

15. A chip, characterized by The chip is verified by a target use case set, and the target use case set is obtained by the method for generating test cases in any one of claims 1-13.

16. A terminal, characterized by The chip of claim 15 is included.

17. An electronic device, comprising: A computer program product comprising a memory, a processor and a computer program stored on the memory and loadable into the processor, the processor implementing the method for generating test cases in any one of claims 1-13 when executing the program.

18. A computer readable storage medium storing a computer program, wherein the computer program comprises instructions that, when executed by a computer, cause the computer to perform the method according to any one of claims 1 to 17. The computer program product is executed by the processor to implement the method for generating test cases in any one of claims 1-13.

19. A computer program product, characterised in that, The computer program product is executed by the processor to implement the method for generating test cases in any one of claims 1-13.

Citation Information

Patent Citations

  • Test case determination method and device and cloud disk regression test method and device

    CN117493174A

  • Random combination test case generation method and system based on multi-dimensional coverage matrix

    CN117520211A