Test case generation method and device, electronic equipment and medium

Through clustering and priority sorting technology, the number of test cases is reduced, the problem of low test efficiency caused by the huge number of test cases in the existing technology is solved, and efficient test case generation is achieved.

CN119396731APending Publication Date: 2025-02-07INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411533388.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-07

AI Technical Summary

Technical Problem

In the prior art, in order to ensure product testing quality, the number of test cases is usually relatively large, resulting in an increase in the writing time of test cases and reducing the testing efficiency.

Method used

By obtaining test points, clustering test points based on text similarity and code coverage similarity, obtaining test points clusters, and prioritizing test points in each test point cluster, eliminating some test points, and generating test cases.

Benefits of technology

While ensuring the quality of the test, the number of test cases is reduced and the testing efficiency is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119396731A_ABST
    Figure CN119396731A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of testing, and particularly discloses a test case generation method and device, electronic equipment and a medium, and the method comprises the steps: obtaining a test point which represents a to-be-tested business function; based on text similarity and code coverage similarity between the test points, the test points are clustered to obtain at least one test point cluster, the text similarity represents the similarity of text vectors of different test points, and the code coverage similarity represents the similarity of program code paths corresponding to different test points; performing priority ranking on the test points in each test point cluster, wherein the priority represents the importance degree of each test point; and according to the priority, rejecting part of the test points, and generating a test case based on the test points which are not rejected. The test efficiency can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] After most products (including hardware and software products) are developed, they need to be tested to detect possible product defects and fix them. During the product testing process, the quality of test cases is the cornerstone of ensuring test quality.

[0003] At present, in order to ensure the testing quality of products, the number of test cases is usually large, which greatly increases the time for writing test cases and reduces testing efficiency. Summary of the invention

[0004] In view of this, the implementation method of the present disclosure provides a test case generation method, a test case generation device, an electronic device, a computer-readable storage medium and a computer program product, which can reduce the number of test cases and improve test efficiency while ensuring the quality of product testing.

[0005] The present disclosure provides a test case generation method, the method comprising:

[0006] Acquire a test point, where the test point represents a service function to be tested;

[0007] Clustering the test points based on the text similarity and code coverage similarity between the test points to obtain at least one test point cluster, wherein the text similarity represents the similarity of text vectors of different test points, and the code coverage similarity represents the similarity of program code paths corresponding to different test points;

[0008] Prioritizing the test points in each of the test point clusters, wherein the priority represents the importance of each of the test points;

[0009] According to the priority, some test points are eliminated, and test cases are generated based on the test points that are not eliminated.

[0010] In one aspect, the present disclosure provides a test case generation device, the device comprising:

[0011] A test point acquisition module, used to acquire test points, wherein the test points represent the service functions to be tested;

[0012] A clustering module, configured to cluster the test points based on text similarity and code coverage similarity between the test points to obtain at least one test point cluster, wherein the text similarity represents the similarity of text vectors of different test points, and the code coverage similarity represents the similarity of program code paths corresponding to different test points;

[0013] A priority sorting module, used to sort the test points in each of the test point clusters respectively, wherein the priority represents the importance of each of the test points;

[0014] The test case generation module is used to eliminate some test points according to the priority, and generate test cases based on the test points that have not been eliminated.

[0015] Another aspect of the present disclosure provides an electronic device, which includes a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method described above is implemented.

[0016] Another aspect of the present disclosure further provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method described above is implemented.

[0017] In the technical solutions of some embodiments of the present application, after clustering the test points based on the text similarity and code coverage similarity between the test points, the same product defect can be detected with a high probability through the test points in the same test point cluster. Therefore, some test points in the same test point cluster can be eliminated according to the priority of the test points, and the corresponding product defects can be detected through the test points that have not been eliminated. In this way, when the detected product defects are not reduced (that is, under the premise of ensuring the test quality), the number of test cases can be greatly reduced, thereby improving the test efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The features and advantages of the present disclosure will be more clearly understood by referring to the accompanying drawings, which are schematic and should not be construed as limiting the present disclosure in any way. In the accompanying drawings:

[0019] Figure 1 A schematic diagram of a flow chart of a test case generation method provided by an embodiment of the present disclosure is shown;

[0020] Figure 2 A schematic diagram showing the overall program code architecture of one of the products provided by one embodiment of the present disclosure;

[0021] Figure 3 A schematic diagram of a clustering process provided by an embodiment of the present disclosure is shown;

[0022] Figure 4 A schematic diagram of a training process of a test case generation model provided by an embodiment of the present disclosure is shown;

[0023] Figure 5 A module schematic diagram of a test case generating device provided by an embodiment of the present disclosure is shown;

[0024] Figure 6 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0025] In order to make the purpose, technical scheme and advantages of the implementation method of the present disclosure clearer, the technical scheme in the implementation method of the present disclosure will be clearly and completely described below in conjunction with the drawings in the implementation method of the present disclosure. Obviously, the implementation method described is a part of the implementation method of the present disclosure, not all of the implementation methods. Based on the implementation method in the present disclosure, all other implementation methods obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.

[0026] In order to ensure the quality of product testing, it is usually necessary to ensure the quality of test cases first. One of the indicators used to evaluate the quality of test cases is the product defect hit rate. Among them, product defects can also be called BUGs. The product defect hit rate refers to the ratio of the number of product defects detected by the test case to the number of defects actually existing in the product. The higher the product defect hit rate, the better the quality of the test case, and the better the corresponding product test quality.

[0027] At present, in order to ensure the quality of product testing, in some technologies, a large number of test cases are designed and manually sorted. In the process of manually sorting the test cases, the importance of each test case is manually judged, and the test cases with high importance are sorted in the front, and the test cases with low importance are sorted in the back. In the process of executing the test cases, only the test cases with high importance can be executed, and the test cases with low importance can not be executed.

[0028] Among these technologies, on the one hand, the number of test cases is too large, and even some test cases that do not need to be executed need to be written with manpower and time, which greatly increases the writing time of test cases and reduces the test efficiency; on the other hand, in the process of manually judging the importance of test cases, different testers may have deviations in judging the importance of each test case, so there may be problems with inaccurate test case sorting, which affects the quality of product testing. For example, some test cases with high importance are sorted at the back, resulting in these test cases not being executed, thus affecting the quality of product testing.

[0029] In view of this, the present disclosure proposes a test case generation method that can solve the above problems. The test case generation method can be applied to electronic devices. The electronic devices include but are not limited to tablet computers, desktop computers, laptop computers, servers, etc. Figure 1 , which is a flow chart of a test case generation method provided by an embodiment of the present disclosure. Figure 1 In the test case generation method, the test case generation method includes the following steps:

[0030] Step S101: acquiring a test point, where the test point represents a service function to be tested.

[0031] Specifically, the relationship between the test points and the test cases can be one-to-one. Each test point can be a part of the corresponding test case. In addition to the test points, each test case can also include test steps, theoretical test results, etc. By executing the test steps, if the actual test results obtained are the same as the theoretical test results in the test case, it can be said that the test for the test point has passed; if the actual test results obtained are different from the theoretical test results in the test case, it can be said that the test for the test point has failed. For example, the second row, the third row, and the fourth row in Table 1 can respectively represent part of the content of one of the test cases for a product.

[0032] Table 1 Test case

[0033]

[0034]

[0035] Take the second row in Table 1 as an example. If after executing the test steps in the second row, the actual test result is that the rename is successful, and the name only accepts a combination of numbers, dots, underscores, and letters, then it means that the test for the test point "Group administrators rename files owned by other users in the global share" has passed. On the contrary, if after executing the test steps in the second row, the actual test result is that the rename fails, or the name can accept other combinations besides numbers, dots, underscores, and letters, it means that the test for the test point "Group administrators rename files owned by other users in the global share" has failed. If the test fails, it may indicate that the product has product defects and these product defects need to be fixed.

[0036] In this embodiment, a product may include multiple modules. For example, a product for file storage management may include a user authentication module, a file upload module, a file download module, a file attribute management module, etc. Each module may include one or more requirements, and each requirement may include one or more test points. Requirements may understand the category to which the test point belongs. In addition to the test point, the test case may also include the requirements and modules to which the test point belongs. The test case in Table 1 may be shown in Table 2:

[0037] Table 2 Test cases

[0038]

[0039]

[0040] In this embodiment, the target fields such as modules, requirements, test points and theoretical test results in the test case can be manually written by the tester, and other fields except the target fields can be automatically generated by the model when executing the following steps S102 and S103. That is, a complete test case is generated by two ways: manual writing by the tester and automatic generation by the model.

[0041] Specifically, in step S101, the test case writing interface can be displayed, and the content written by the tester in the writing interface is used as the obtained modules, requirements, test points, theoretical test results, etc. Of course, the file import interface can also be displayed, and the modules, requirements, test points, theoretical test results, etc. are obtained according to the file imported by the tester in the file import interface.

[0042] Step S102, clustering the test points based on the text similarity and code coverage similarity between the test points to obtain at least one test point cluster, wherein the text similarity represents the similarity of text vectors of different test points, and the code coverage similarity represents the similarity of program code paths corresponding to different test points.

[0043] Among them, text similarity can be understood as text semantic similarity, that is, the more similar the text semantics of two test points are, the higher the text similarity between the two test points is. The text similarity between the test points can be determined by calculating the distance between the text vectors of the test points. Specifically, the larger the distance between the text vectors of the two test points, the smaller the text similarity between the two test points is, and the smaller the distance between the text vectors of the two test points is, the greater the text similarity between the two test points is. The higher the text similarity between the two test points, the higher the probability of detecting the same product defect through the two test points.

[0044] Each test point can have its own corresponding program code. By running the program code corresponding to the test point, the business function corresponding to the test point can be realized (that is, the program code corresponding to each test point can also be understood as the business function program code). Testing the test point is to detect whether there are defects in the program code logic corresponding to the test point.

[0045] The program codes corresponding to multiple test points are allowed to be combined into the overall program code. Specifically, in the overall program code, the program codes corresponding to each test point can be combined according to the architecture such as modules, requirements, test points, etc. In this way, in the overall program code, the program codes corresponding to each test point can each correspond to a program code path. The program code path represents the position of the program code corresponding to each test point in the overall program code, and each program code path is allowed to be divided into one or more sub-paths. For ease of understanding, please refer to Figure 2 , which is a schematic diagram of the architecture of the overall program code of one of the products provided in one embodiment of the present disclosure. Figure 2 Take test point A111 and test point B132 as examples. The program code corresponding to test point A111 can be placed under the program code path of product>module A1>requirement A11>test point A111, and the program code corresponding to test point B132 can be placed under the program code path of product>module B1>requirement B13>test point B132. Further, take the program code path corresponding to test point A111 as an example. The program code path can be divided into three sub-paths: product>module A1, module A1>requirement A11, and requirement A11>test point A111.

[0046] Based on the above description, in this embodiment, the code coverage similarity between two test points can be obtained based on the following method:

[0047] 1) For a first test point and a second test point of two test points, a first program code path corresponding to the first test point and a second program code path corresponding to the second test point are obtained.

[0048] 2) When there are overlapping sub-paths between the first program code path and the second program code path, determine the number of overlapping sub-paths.

[0049] The so-called overlapping subpath refers to the same subpath in the first program code path and the second program code path. Figure 2 Take the first program code path corresponding to the test point A111 and the second program code path corresponding to the test point A121 in as an example. The overlapping subpaths of these two program code paths are product>module A1, and the number of corresponding overlapping subpaths is 1. For another example, Figure 2Take the first program code path corresponding to the test point A111 and the second program code path corresponding to the test point A112 in as an example. The overlapping subpaths of these two program code paths are product>module A1, module A1>module A11, and the number of corresponding overlapping subpaths is 2.

[0050] 3) Determine the total number of sub-paths included in the first program code path and the second program code path.

[0051] Specifically, when calculating the total number of sub-paths, the overlapping sub-paths in the first program code path and the second program code path are counted only once. Figure 2 In the example, the first program code path corresponding to test point A111 and the second program code path corresponding to test point A112 include overlapping sub-paths product>module A1 and module A1>module A11, but sub-path product>module A1 can be counted only once, and sub-path module A1>module A11 can also be counted only once. In this way, the total number of sub-paths included in the first program code path and the second program code path is 4.

[0052] 4) Taking the number of overlapping sub-paths as the numerator and the total number of sub-paths as the denominator, determine the ratio between the number of overlapping sub-paths and the total number of sub-paths.

[0053] For example, still Figure 2 Take the first program code path corresponding to the test point A111 and the second program code path corresponding to the test point A112 in as an example. The number of overlapping subpaths of the two program code paths is 2, and the total number of included subpaths is 4, so the number ratio is 0.5.

[0054] 5) Convert the quantity ratio to obtain the code coverage similarity between the first test point and the second test point, wherein the quantity ratio is proportional to the code coverage similarity.

[0055] Specifically, the obtained quantitative ratio can be directly used as the code coverage similarity between the first test point and the second test point, or the quantitative ratio can be converted into other values ​​(such as converting 0.5 into 5) according to the principle that the quantitative ratio is proportional to the code coverage similarity, and the converted value is used as the code coverage similarity between the first test point and the second test point. This application does not limit the specific conversion process.

[0056] Generally speaking, if the code coverage similarity between two test points is higher, the probability of detecting the same product defect through the two test points can be higher.

[0057] In this embodiment, the text similarity and code coverage similarity of two test points can be comprehensively considered to cluster the test points. Specifically, for any two test points, if the text similarity of the two test points is higher than a first threshold and the code coverage similarity is higher than a second threshold, the two test points can be placed in the same test point cluster. In this way, the test points in the same test point cluster can have a higher probability of detecting the same product defect.

[0058] Furthermore, for any two test points, if any of the following conditions are met, the two test points can be placed in different test point clusters:

[0059] Case 1: The text similarity of the two test points is higher than the first threshold but the code coverage similarity is not higher than the second threshold;

[0060] Case 2: The code coverage similarity of the two test points is higher than the second threshold, but the text similarity is not higher than the first threshold

[0061] Case 3: The text similarity of the two test points is not higher than the first threshold and the code coverage similarity is not higher than the second threshold.

[0062] Among them, case 3 is relatively easy to understand, that is, based on the text similarity and code coverage similarity, it is determined that the probability of detecting the same product defect through the two test points is low, so the two test points can be placed in different test point clusters. For cases 1 and 2, it means that the text similarity and code coverage similarity can be mutually corrected to obtain the correct clustering result. For example, suppose that in a product, the length of the file name is limited to 35 characters. Based on this limitation, two test points can be set. One of the test points A is "set the length of the file name to 30 characters", and the other test point B is "set the length of the file name to 36 characters". Although the similarity of these two test points is very high in terms of text similarity. However, the program codes corresponding to these two test points may be quite different. For example, the program code corresponding to test point A should be the program code that normally modifies the file name and prompts the modification is successful, and the program code corresponding to test point B may not modify the file name and prompt the modification failed. Due to the large difference in program code (the program code paths corresponding to these two test points will also be quite different), the probability of detecting the same program defect based on these two test points is low. Therefore, these two test points need to be placed in different test point clusters.

[0063] In some other embodiments, a first weight may be set for text similarity, and a second weight may be set for code coverage similarity. The product of the calculated text similarity and the first weight may be used as the final text similarity, and the product of the calculated code coverage similarity and the second weight may be used as the final code coverage similarity. Wherein, when the first weight is greater than the second weight, it means that in the clustering process, the text similarity between the test points is emphasized; when the second weight is greater than the first weight, it means that in the clustering process, the code coverage similarity between the test points is emphasized. In this way, based on the first weight and the second weight, the importance of text similarity and code coverage similarity in clustering can be adjusted to facilitate manual adjustment of the clustering results.

[0064] In some other embodiments of the present disclosure, a better clustering method is provided. For details, please refer to the subsequent related descriptions, which will not be repeated here.

[0065] Step S103 , prioritizing the test points in each test point cluster, wherein the priority represents the importance of each test point.

[0066] Specifically, the test points in each test point cluster can be sorted by multiple objectives based on the non-dominated sorting genetic algorithm NSGA-II, so that the test points with a higher probability of detecting product defects (i.e., test points with high priority) are placed in front, and the test points with a lower probability of detecting product defects (i.e., test points with low priority) are placed in the back.

[0067] In some other embodiments of the present disclosure, a better priority sorting method is provided. For details, please refer to the subsequent related descriptions and will not be repeated here.

[0068] Step S104: remove some test points according to their priorities, and generate test cases based on the test points that have not been removed.

[0069] Specifically, based on the description of step S102, since the test points in each test point cluster are test points with a greater probability of detecting the same product defect, some test points may be deleted in each test point cluster to reduce the number of test points.

[0070] In this embodiment, considering that the test points with high priority are more important, in order to avoid accidental deletion, some test points with low priority can be deleted in each test point cluster.

[0071] In some other embodiments of the present disclosure, a better test point deletion method is provided. For details, please refer to the subsequent related descriptions, which will not be repeated here.

[0072] In this embodiment, the first feature information extracted from the test points that have not been eliminated and the second feature information extracted from the requirement document corresponding to the test points can be input into the trained test case generation model, and the test case generation model generates a complete test case.

[0073] In summary, in the technical solutions of some embodiments of the present application, after clustering the test points based on the text similarity and code coverage similarity between the test points, the same product defect can be detected with a high probability through the test points in the same test point cluster. Therefore, some test points in the same test point cluster can be eliminated according to the priority of the test points, and the corresponding product defects can be detected through the test points that have not been eliminated. In this way, when the detected product defects are not reduced (that is, under the premise of ensuring the test quality), the number of test cases can be greatly reduced, thereby improving the test efficiency.

[0074] In some embodiments, clustering the test points based on the text similarity and code coverage similarity between the test points in step S102 may include:

[0075] In a case where the text similarity between the two test points is higher than a first threshold, if the code coverage similarity between the two test points is lower than a second threshold, adjusting the text similarity between the two test points to be lower than or equal to the first threshold;

[0076] Based on the adjusted text similarity, the test points are clustered.

[0077] In simple terms, code coverage similarity is used to correct text similarity before clustering, and then, during the clustering process, test points can be clustered based only on the corrected text similarity. In this way, there is no need to consider two similarities at the same time during the clustering process, which greatly simplifies the clustering process.

[0078] In some embodiments, adjusting the text similarity between the two test points to be lower than or equal to the first threshold may include:

[0079] For one of the two test points, a target test point is adjusted by setting a weight for the text vector of the target test point, so as to adjust the text similarity between the two test points to be lower than or equal to a first threshold.

[0080] Specifically, after adjusting the text vector of the target test point, the text vector distance between the target test point and another test point can be increased, and the text similarity between the two test points can be adjusted to be lower than or equal to the first threshold. For example, assuming that before the text vector adjustment, the text vector of the target test point is 0.12, and the text vector of the other test point is 0.11, then the text vector distance between the two test points is 0.01. Since the text vector distance is small, the text similarity between the two test points can be greater than the first threshold. In this case, a weight can be set for the target test point, such as setting a weight of 0.1 for the target test point, and after multiplying the weight by the text vector of the target test point of 0.12, the text vector of the target test point becomes 0.012. At this time, the text vector distance between the two test points becomes 0.098. In this way, the text vector distance between the two test points is increased, and then the text similarity between the two test points can be adjusted to be lower than or equal to the first threshold.

[0081] In the above embodiment, by setting a weight for the text vector of the target test point, the text vector of the target test point is adjusted, and then the text similarity between the two test points is adjusted, thereby increasing the flexibility of the solution.

[0082] In some embodiments, in conjunction with Figure 3 , is a schematic diagram of a clustering process provided by an embodiment of the present disclosure. Clustering test points may include:

[0083] According to the adjusted text similarity, the test points are first clustered to obtain a plurality of test point sub-clusters, and according to the similarity between each test point sub-clusters, the test point sub-clusters are clustered to obtain a test point cluster.

[0084] Specifically, Figure 3 In the figure, the C0 stage corresponds to the test points, the C1 stage corresponds to multiple test point sub-clusters obtained after the test points are first clustered, and the C2 stage corresponds to the test point clusters obtained after clustering the test point sub-clusters.

[0085] When clustering the test point subclusters, the text similarities of the test points in each test point subcluster can be averaged to obtain the average text similarity of each test point subcluster, and the test point subclusters can be clustered based on the average text similarity.

[0086] The clustering accuracy can be improved by clustering test points at multiple levels.

[0087] In some embodiments, the priority sorting of the test points in each test point cluster in step S103 may include:

[0088] For a test point sub-cluster in one of the test point clusters, the test points in each test point sub-cluster are prioritized to obtain a test point ranking list corresponding to each test point sub-cluster;

[0089] A specified number of test points are obtained from each test point list in a loop, and the test points are combined in the order in which they are obtained, so as to prioritize the test points in the test point cluster.

[0090] For example, suppose that after the test points in the test point sub-cluster a are prioritized, the test point ranking list a obtained is: test point a1>test point a2>test point a3. Among them, the priority of test point a1 is higher than that of test point a2, and the priority of test point a2 is higher than that of test point a3.

[0091] After the test points in the test point sub-cluster b are prioritized, the obtained test point ranking list b is: test point b1>test point b2>test point b3>test point b4. Among them, the priority of test point b1 is higher than that of test point b2, the priority of test point b2 is higher than that of test point b3, and the priority of test point b3 is higher than that of test point b4.

[0092] After the test points in the test point sub-cluster c are prioritized, the obtained test point ranking list c is: test point c1>test point c2>test point c3. Among them, the priority of test point c1 is higher than that of test point c2, and the priority of test point c2 is higher than that of test point c3.

[0093] Looping to obtain a specified number of test points from each test point list and combining the test points in the order in which they are obtained can be a process similar to the following:

[0094] Take out test point a1 from test point sorting list a, take out test point b1 from test point sorting list b, take out test point c1 from test point sorting list c, and put test points a1, b1, and c1 in the front;

[0095] Then, take out the test point a2 from the test point sorting list a, take out the test point b2 from the test point sorting list b, take out the test point c2 from the test point sorting list c, and put the test points a2, b2, and c2 after the test points a1, b1, and c1;

[0096] Then, take out the test point a3 from the test point sorting list a, take out the test point b3 from the test point sorting list b, take out the test point c3 from the test point sorting list c, and put the test points a3, b3, and c3 after the test points a2, b2, and c2;

[0097] Then, test point b4 is taken out from the test point sorting list b, and is arranged after test points a3, b3, and c3.

[0098] In this way, the test points with higher priorities in each test point sub-cluster can be arranged in the front, and the test points with lower priorities in each test point sub-cluster can be arranged in the back, thereby ensuring the accuracy of the sorting.

[0099] In some embodiments, removing some test points according to priority in step S104 may include:

[0100] Among the test points whose priorities are lower than the third threshold, searching for the third test point and the fourth test point whose correlation is higher than the fourth threshold, wherein the correlation represents the probability of detecting the same product defect in the process of testing the third test point and the fourth test point;

[0101] Eliminate one of the third test point and the fourth test point.

[0102] The test point with a priority lower than the third threshold may be a test point with a lower priority. Among the third test point and the fourth test point with a correlation higher than the fourth threshold, only one of the test points is removed to reduce the probability of erroneous deletion of the test point.

[0103] In some embodiments, the correlation between the third test point and the fourth test point is obtained based on the following method:

[0104] Obtain historical test data for the third test point and the fourth test point;

[0105] Determine, based on historical test data, an execution failure relationship between the third test point and the fourth test point, wherein the execution failure relationship indicates whether the third test point fails to be tested when the third test point fails to be tested;

[0106] Based on the execution failure relationship, a correlation between the third test point and the fourth test point is determined.

[0107] Specifically, the historical test data may be the test data of the module. The test case in the present application method may be a test case when performing an integration test on multiple modules. When performing an integration test on multiple modules, each module will be tested separately, so the corresponding historical test data can be obtained.

[0108] Specifically, if the third test point fails to be tested, the fourth test point also fails to be tested, which means that the probability of detecting the same product defect through the third test point and the fourth test point is relatively high (i.e., the correlation is relatively high), and therefore, one of the third test point and the fourth test point can be deleted. Conversely, if the third test point fails to be tested, the fourth test point does not fail to be tested, which means that the probability of detecting the same product defect through the third test point and the fourth test point is relatively low (i.e., the correlation is relatively low), and the third test point and the fourth test point can be retained at the same time. In this way, the situation of accidental deletion of test points can be prevented.

[0109] Combined with reference Figure 4 , is a schematic diagram of the training process of the test case generation model provided by an embodiment of the present disclosure. Specifically, when training the test case generation model, the following steps may be included:

[0110] 41) Collect historical project documents and use them as original data. The historical project-related documents may include requirement documents, test points, and test cases corresponding to the test points.

[0111] 42) Use word segmentation tools to extract keywords from requirement documents and test points to obtain a keyword set, and label, step, and hot-read encode test cases to obtain a test case label set.

[0112] 43) Constructing a training data set for a test case generation model based on the keyword set and the test case label set, wherein keyword extraction may include key term extraction, expected results, etc., to obtain keyword samples and test case step identifiers.

[0113] 44) The training data set is input into a test case generation model based on a neural network so that the test case generation model outputs a test case.

[0114] 45) Manually intervene to correct the test cases, and use the corrected test cases as training data sets to reversely input the test case generation model to fine-tune the test case generation model.

[0115] Figure 4 In the process generation, the test cases are classified into categories according to the business scenarios they correspond to, and the test cases are classified into categories according to the execution processes they correspond to.

[0116] This completes the entire description of the disclosed method.

[0117] Corresponding to the test case generation method, the present disclosure also provides a test case generation device. Figure 5 , which is a module diagram of a test case generation device provided by an embodiment of the present disclosure. Figure 5 In the test case generation device, the test case generation device includes:

[0118] A test point acquisition module is used to acquire test points, where the test points represent the business functions to be tested;

[0119] A clustering module, used for clustering the test points based on the text similarity and code coverage similarity between the test points to obtain at least one test point cluster, wherein the text similarity represents the similarity of the text vectors of different test points, and the code coverage similarity represents the similarity of the program code paths corresponding to the different test points;

[0120] A priority sorting module is used to sort the test points in each test point cluster respectively, and the priority represents the importance of each test point;

[0121] The test case generation module is used to eliminate some test points according to priority, and generate test cases based on the test points that have not been eliminated.

[0122] In some embodiments, the clustering module is specifically configured to:

[0123] In a case where the text similarity between the two test points is higher than a first threshold, if the code coverage similarity between the two test points is lower than a second threshold, adjusting the text similarity between the two test points to be lower than or equal to the first threshold;

[0124] Based on the adjusted text similarity, the test points are clustered.

[0125] In some embodiments, program codes corresponding to multiple test points are allowed to be combined into a total program code; the clustering module is specifically used to obtain the code coverage similarity between two test points based on the following method:

[0126] For a first test point and a second test point of the two test points, obtaining a first program code path corresponding to the first test point and a second program code path corresponding to the second test point, wherein the program code path represents a position of the program code corresponding to each test point in the total program code, and each program code path is allowed to be divided into one or more sub-paths;

[0127] In the case where there are overlapping subpaths in the first program code path and the second program code path, determining the number of overlapping subpaths;

[0128] Determine the total number of sub-paths included in the first program code path and the second program code path;

[0129] Taking the number of overlapping subpaths as a numerator and the total number of subpaths as a denominator, determine the ratio between the number of overlapping subpaths and the total number of subpaths;

[0130] The quantity ratio is converted to obtain the code coverage similarity between the first test point and the second test point, wherein the quantity ratio is proportional to the code coverage similarity.

[0131] In some embodiments, the clustering module is specifically configured to:

[0132] For one of the two test points, a target test point is adjusted by setting a weight for the text vector of the target test point, so as to adjust the text similarity between the two test points to be lower than or equal to a first threshold.

[0133] In some embodiments, the clustering module is specifically configured to:

[0134] According to the adjusted text similarity, the test points are first clustered to obtain multiple test point sub-clusters;

[0135] According to the similarity between each test point sub-cluster, the test point sub-clusters are clustered to obtain the test point cluster.

[0136] In some embodiments, the priority sorting module is specifically configured to:

[0137] For a test point sub-cluster in one of the test point clusters, the test points in each test point sub-cluster are prioritized to obtain a test point ranking list corresponding to each test point sub-cluster;

[0138] A specified number of test points are obtained from each test point list in a loop, and the test points are combined in the order in which they are obtained, so as to prioritize the test points in the test point cluster.

[0139] In some embodiments, the test case generation module is specifically used to:

[0140] Among the test points whose priorities are lower than the third threshold, searching for the third test point and the fourth test point whose correlation is higher than the fourth threshold, wherein the correlation represents the probability of detecting the same product defect in the process of testing the third test point and the fourth test point;

[0141] Eliminate one of the third test point and the fourth test point.

[0142] In some embodiments, the test case generation module is specifically used to obtain the correlation between the third test point and the fourth test point based on the following method:

[0143] Obtain historical test data for the third test point and the fourth test point;

[0144] Determine, based on historical test data, an execution failure relationship between the third test point and the fourth test point, wherein the execution failure relationship indicates whether the third test point fails to be tested when the third test point fails to be tested;

[0145] Based on the execution failure relationship, a correlation between the third test point and the fourth test point is determined.

[0146] Combined with reference Figure 6 , is a schematic diagram of an electronic device provided by an embodiment of the present disclosure. The electronic device includes a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the above method is implemented.

[0147] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.

[0148] As a non-transitory computer-readable storage medium, the memory can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor executes various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory, that is, implementing the method in the above method embodiment.

[0149] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-transitory memory, such as at least one disk storage device, a flash memory device, or other non-transitory solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0150] An embodiment of the present disclosure further provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the above method is implemented.

[0151] Although the implementation method of the present disclosure has been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present disclosure, and such modifications and variations are all within the scope defined by the appended claims.

Claims

1. A test case generation method, characterized in that: The method comprises: Acquire a test point, where the test point represents a service function to be tested; Clustering the test points based on the text similarity and code coverage similarity between the test points to obtain at least one test point cluster, wherein the text similarity represents the similarity of text vectors of different test points, and the code coverage similarity represents the similarity of program code paths corresponding to different test points; Prioritizing the test points in each of the test point clusters, wherein the priority represents the importance of each of the test points; According to the priority, some test points are eliminated, and test cases are generated based on the test points that are not eliminated.

2. The method according to claim 1, characterized in that The clustering of the test points based on the text similarity and code coverage similarity between the test points includes: In a case where the text similarity between two test points is higher than a first threshold, if the code coverage similarity between the two test points is lower than a second threshold, adjusting the text similarity between the two test points to be lower than or equal to the first threshold; The test points are clustered based on the adjusted text similarity.

3. The method according to claim 2, characterized in that The program codes corresponding to the multiple test points are allowed to be combined into a total program code; The code coverage similarity between the two test points is obtained based on the following method: For a first test point and a second test point of the two test points, obtaining a first program code path corresponding to the first test point and a second program code path corresponding to the second test point, wherein the program code path represents a position of the program code corresponding to each of the test points in the total program code, and each of the program code paths is allowed to be divided into one or more sub-paths; In the case where there are overlapping sub-paths between the first program code path and the second program code path, determining the number of the overlapping sub-paths; Determine the total number of sub-paths included in the first program code path and the second program code path; Taking the number of the overlapping subpaths as a numerator and the total number of the subpaths as a denominator, determining a quantity ratio between the number of the overlapping subpaths and the total number of the subpaths; The quantity ratio is converted to obtain the code coverage similarity between the first test point and the second test point, wherein the quantity ratio is proportional to the code coverage similarity.

4. The method according to claim 2, characterized in that The step of adjusting the text similarity between the two test points to be lower than or equal to the first threshold comprises: For one target test point among the two test points, a weight is set for the text vector of the target test point to adjust the text vector of the target test point, so as to adjust the text similarity between the two test points to be lower than or equal to the first threshold.

5. The method according to claim 2, characterized in that The clustering of the test points comprises: According to the adjusted text similarity, performing a first clustering on the test points to obtain a plurality of test point sub-clusters; The test point subclusters are clustered according to the similarities between the test point subclusters to obtain the test point cluster.

6. The method according to claim 5, characterized in that The prioritizing the test points in each of the test point clusters respectively includes: For a test point sub-cluster in one of the test point clusters, respectively prioritize the test points in each of the test point sub-clusters to obtain a test point ranking list corresponding to each of the test point sub-clusters; A specified number of test points are obtained from each of the test point lists in a loop, and the test points are combined in the order of obtaining, so as to prioritize the test points in the test point cluster.

7. The method according to claim 1, characterized in that Eliminating some test points according to the priority includes: Among the test points whose priorities are lower than the third threshold, searching for a third test point and a fourth test point whose correlation is higher than a fourth threshold, wherein the correlation represents the probability of detecting the same product defect in the process of testing the third test point and the fourth test point; One of the third test point and the fourth test point is eliminated.

8. The method according to claim 7, characterized in that The correlation between the third test point and the fourth test point is obtained based on the following method: Acquire historical test data for the third test point and the fourth test point; determining, according to the historical test data, an execution failure relationship between the third test point and the fourth test point, wherein the execution failure relationship indicates whether the third test point is tested failed when the third test point is tested failed; Based on the execution failure relationship, a correlation between the third test point and the fourth test point is determined.

9. A test case generating device, characterized in that: The device comprises: A test point acquisition module, used to acquire test points, wherein the test points represent the service functions to be tested; A clustering module, configured to cluster the test points based on text similarity and code coverage similarity between the test points to obtain at least one test point cluster, wherein the text similarity represents the similarity of text vectors of different test points, and the code coverage similarity represents the similarity of program code paths corresponding to different test points; A priority sorting module, used to sort the test points in each of the test point clusters respectively, wherein the priority represents the importance of each of the test points; The test case generation module is used to eliminate some test points according to the priority, and generate test cases based on the test points that have not been eliminated.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium is used to store a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.

11. An electronic device, characterized in that: The electronic device comprises a processor and a memory, wherein the memory is used to store a computer program, and when the computer program is executed by the processor, the method according to any one of claims 1 to 8 is implemented.