A method, apparatus, electronic device, and storage medium for determining test cases

Through the spanning tree model, the high cost and error problems caused by human selection are solved, and efficient and full coverage regression testing is achieved.

CN114490404BActive Publication Date: 2025-07-04AGRICULTURAL BANK OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210124049.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-10
Publication Date
2025-07-04
Estimated Expiration
2042-02-10

AI Technical Summary

Technical Problem

In the existing regression testing technology, there are high costs and large errors in artificially selected test cases, resulting in unsatisfactory coverage and high execution costs, making it difficult to efficiently select test cases while ensuring full coverage.

Method used

By obtaining the correlation data of historical test cases and data to be tested, generating initial and matching spanning tree models, determining intersection test case data, and determining target test cases based on the use case weight, using spanning tree model to establish the association relationship between test requirements and historical test cases, and optimizing the selection of test cases.

Benefits of technology

On the premise of ensuring full coverage of test requirements, reduce labor costs and selection errors, improve the execution efficiency of regression tests, avoid redundant test case selection, and save labor and time costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490404B_ABST
    Figure CN114490404B_ABST
Patent Text Reader

Abstract

An embodiment of the present invention discloses a test case determination method, device, electronic device, and storage medium. The test case determination method includes: obtaining test case associated data; wherein the test case associated data includes historical test cases, data to be tested, and case weights; generating an initial spanning tree model based on the historical test cases, and generating a to-be-matched spanning tree model based on the data to be tested; determining intersection test case data between the initial spanning tree model and the to-be-matched spanning tree model; and determining target test cases according to the intersection test case data and the case weights matching the intersection test case data. The technical solution of the embodiment of the present invention can save the labor cost of selecting test cases, reduce the selection error caused by manual selection of test cases, and improve the execution efficiency of regression testing on the premise of ensuring full coverage of test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present invention relate to the technical field of regression testing, and in particular, to a method, apparatus, electronic device, and storage medium for determining test cases. Background Technique

[0002] Software testing has emerged along with software. Bill Hetzel pointed out in the book "Complete Guide to Software Testing" that "testing is any activity aimed at evaluating the properties of a program or system, and testing is a measure of software quality." The definition of software testing given in the software engineering terms proposed by the IEEE in 1983 is: "The process of using manual or automated means to run or measure a software system, with the aim of verifying whether it meets the specified requirements or clarifying the difference between the expected result and the actual result." The purpose of software testing is to verify whether the software system meets the requirements and integrate it into the entire development process. As an integral part of the software life cycle, regression testing accounts for a large proportion of the workload in the entire software testing process. For a software development project, the test team of the project will maintain and manage the test case libraries of different versions of the software during the testing process. When regression testing is required, appropriate automated or manual test cases can be selected from the corresponding case libraries according to the regression testing strategy to form a regression test set for regression testing. Regression testing requires time and manpower for planning and implementation. In order to perform regression testing as efficiently as possible within the given time and manpower, it is necessary to select the regression test case set as accurately as possible. On the premise of being able to fully cover the function modules to be tested, the smaller the test case set, the less the human and time costs consumed.

[0003] Currently, the regression test case set can be mainly selected through the following three methods. The first method is: by decomposing the test requirements, constructing a binary relationship matrix model by prioritizing the correlation degree between the regression test cases and the decomposed test requirement points. The correlation degree between the test cases and the requirement points is represented by the coverage rate, and the greedy strategy is used to screen the smallest test case set that covers the most requirements. The second method is: reducing the regression test cases based on code coverage. This method constructs a fitness function based on the test code coverage rate and the test time cost, and uses the genetic algorithm to reduce the regression test cases. The third method is: obtaining the code coverage rate through the built-in plug-in of the GCC compiler, considering the optimization indicators of both code coverage rate and time overhead, and using MOEA / D (Multi-Objective Evolutionary Algorithm) to reduce and optimize the regression test case set.

[0004] However, in the first method, after artificially decomposing the test requirements, the human judgment of the association relationship between the test cases and the decomposed requirement points leads to the problem of insufficient accuracy of the selected test cases, and the manual screening cost is relatively high. Although the second method and the third method consider both the test code coverage and the execution cost at the same time, the second method and the third method still belong to the artificial selection of test cases and do not conduct targeted analysis on the test requirements, and cannot give a reduction method that not only meets the test requirements but also ensures full coverage of the test cases. For the several selection strategies of the test cases in the existing regression testing, no matter which strategy is selected, it is a manual selection when selecting the test cases. The selection based on human experience will inevitably bring errors to the scope decision of the regression test cases. Moreover, when there are a large number of repetitions or redundancies in the coverage of the selected test cases, the human and time costs of executing the test cases will increase significantly, and there may also be situations where the coverage is incomplete or the execution cost is too high. Summary of the Invention

[0005] An embodiment of the present invention provides a test case determination method, device, electronic device and storage medium, which can save the labor cost of selecting test cases, reduce the selection error caused by artificial selection of test cases, and improve the execution efficiency of regression testing on the premise of ensuring full coverage of test cases.

[0006] In a first aspect, an embodiment of the present invention provides a test case determination method, including:

[0007] Obtain test case association data; wherein, the test case association data includes historical test cases, data to be tested, and case weights;

[0008] Generate an initial spanning tree model according to the historical test cases, and generate a to-be-matched spanning tree model according to the data to be tested;

[0009] Determine the intersection test case data of the initial spanning tree model and the to-be-matched spanning tree model;

[0010] Determine the target test cases according to the intersection test case data and the case weights matching the intersection test case data.

[0011] In a second aspect, an embodiment of the present invention further provides a test case determination device, including:

[0012] A data acquisition module, configured to acquire test case association data; wherein, the test case association data includes historical test cases, data to be tested, and case weights;

[0013] A tree model generation module, configured to generate an initial spanning tree model according to the historical test cases, and generate a to-be-matched spanning tree model according to the data to be tested;

[0014] The first data determination module is configured to determine the intersection test case data between the initial generation tree model and the generation tree model to be matched;

[0015] The second data determination module is configured to determine the target test case according to the intersection test case data and the use case weight that matches the intersection test case data.

[0016] In a third aspect, an embodiment of the present invention further provides an electronic device, where the electronic device includes:

[0017] One or more processors;

[0018] A storage device for storing one or more programs;

[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the test case determination method provided in any embodiment of the present invention.

[0020] In a fourth aspect, an embodiment of the present invention further provides a computer storage medium, on which a computer program is stored, and when the program is executed by a processor, the test case determination method provided in any embodiment of the present invention is implemented.

[0021] The technical solution of this embodiment is to obtain the test case association data including historical test cases, data to be tested, and use case weights, and then generate an initial generation tree model according to the historical test cases, and generate a generation tree model to be matched according to the data to be tested, so as to determine the intersection test case data between the initial generation tree model and the generation tree model to be matched, and thus determine the target test case according to the intersection test case data and the use case weight that matches the intersection test case data. In this solution, both historical test cases and data to be tested are converted into tree models, which can intuitively establish the association relationship between test requirements and historical test cases, and facilitate the display and storage of model-based historical test cases and data to be tested. The determined intersection test case data can accurately reflect the characteristics of the test cases required to fully cover the generation tree model to be matched. Therefore, determining the target test case according to the intersection test case data and the use case weight reflecting the use case execution cost during historical testing can screen out the test cases with the lowest test cost on the premise of ensuring full coverage of test requirements, avoid redundancy in the selection of test cases, and thus improve the execution efficiency of regression testing, solving the problems of high labor cost, large selection error, unsatisfactory coverage, and high execution cost existing in the artificial selection of test cases in the prior art, being able to save the labor cost of selecting test cases, reduce the selection error caused by artificial selection of test cases, and improve the execution efficiency of regression testing on the premise of ensuring full coverage of test cases. Description of the Drawings

[0022] Figure 1It is a flowchart of a test case determination method provided in the first embodiment of the present invention;

[0023] Figure 2 It is a flowchart of a test case determination method provided in the second embodiment of the present invention;

[0024] Figure 3 It is a schematic diagram of an initial spanning tree model of a forest structure provided in the second embodiment of the present invention;

[0025] Figure 4 It is an initial spanning tree model for identifying a spanning tree model to be matched provided in the second embodiment of the present invention;

[0026] Figure 5 It is a simple logic diagram of a test case determination method provided in the second embodiment of the present invention;

[0027] Figure 6 It is a schematic diagram of a minimum spanning tree provided in the second embodiment of the present invention;

[0028] Figure 7 It is a schematic diagram of the global nodes of the intersection of historical test case 1 and the spanning tree model to be matched provided in the second embodiment of the present invention;

[0029] Figure 8 It is a schematic diagram of the global nodes of the intersection of historical test case 2 and the spanning tree model to be matched provided in the second embodiment of the present invention;

[0030] Figure 9 It is a schematic diagram of the global nodes of the intersection of historical test case 3 and the spanning tree model to be matched provided in the second embodiment of the present invention;

[0031] Figure 10 It is a schematic diagram of a test case determination device provided in the third embodiment of the present invention;

[0032] Figure 11 It is a schematic diagram of the structure of an electronic device provided in the fourth embodiment of the present invention. Detailed implementation manners

[0033] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It can be understood that the specific embodiments described herein are only for explaining the present invention, rather than limiting the present invention.

[0034] It should also be noted that, for ease of description, only the part relevant to the present invention but not all content is shown in the accompanying drawings. It should be mentioned before discussing exemplary embodiments in more detail that some exemplary embodiments are described as processing or methods depicted as flow charts. Although the flow chart describes each operation (or step) as sequential processing, many operations therein can be implemented in parallel, concurrently or simultaneously. In addition, the order of each operation can be rearranged. When its operation is completed, the processing can be terminated, but it can also have additional steps not included in the accompanying drawings. The processing can correspond to methods, functions, procedures, subroutines, subprograms, etc.

[0035] Embodiment 1

[0036] Figure 1 This is a flowchart of a test case determination method provided by the first embodiment of the present invention. This embodiment is applicable to the case of automatically and accurately selecting regression test cases. The method can be executed by a test case determination device, which can be implemented by software and / or hardware and can generally be integrated in an electronic device. The electronic device can be a terminal device or a server device. The embodiment of the present invention does not limit the type of electronic device that executes the test case determination method. Accordingly, Figure 1 As shown, the method includes the following operations:

[0037] S110. Obtain test case related data.

[0038] Among them, the test case associated data may be data associated with the test case that meets the test requirements, and is used to determine the test case that meets the test requirements. The test case associated data may include historical test cases, data to be tested, and case weights. Historical test cases may be test cases used in historically executed regression tests. The data to be tested may be data that meets the test requirements and is used for regression testing. Exemplarily, the data to be tested may include the function code to be tested and / or the change code, etc. The function code to be tested may be the test code of the original function module of the system. The change code may be the test code of a newly added module in the system, or the test code after the function of a function module is updated. The case weight may be a weight value preset according to the historical test situation of the historical test case.

[0039] In an embodiment of the present invention, test case association data can be obtained in real time or by parsing offline data to determine a test case set that fully covers the test requirements and has the lowest test cost based on the test case association data. Optionally, historical test cases can be determined based on historically executed regression tests, case weights that match historical test cases can be determined based on historical test conditions, and data to be tested can be determined based on current regression test requirements.

[0040] Exemplarily, if the execution cost of historical test case 1 is higher than that of historical test case 2 when performing historical regression testing, a higher use case weight can be set for historical test case 1 than for historical test case 2.

[0041] S120. Generate an initial spanning tree model based on historical test cases, and generate a to-be-matched spanning tree model based on the data to be tested.

[0042] Among them, the initial spanning tree model can be a tree structure determined according to historical test cases. The to-be-matched spanning tree model can be a tree structure determined according to the data to be tested.

[0043] In the embodiments of the present invention, the test case associated data can be parsed to determine historical test cases and the data to be tested. Furthermore, under the same tree structure generation rule, an initial spanning tree model is generated based on historical test cases, and a to-be-matched spanning tree model is generated based on the data to be tested.

[0044] Optionally, an initial spanning tree model can be generated by one historical test case, or an initial spanning tree model can be generated by multiple historical test cases, or multiple initial spanning tree models can be generated by multiple historical test cases. When multiple initial spanning tree models are generated by multiple historical test cases, the multiple initial spanning tree models can form a forest structure, and the test systems matched by the initial spanning tree models in the forest structure can be different. The embodiments of the present invention do not limit the number of historical test cases and the number of generated initial spanning tree models.

[0045] S130. Determine the intersection test case data of the initial spanning tree model and the to-be-matched spanning tree model.

[0046] Among them, the intersection test case data can be the associated data representing at least one historical test case determined according to the intersection of the initial spanning tree model and the to-be-matched spanning tree model. Exemplarily, the intersection test case data can include the names of the historical test cases where the initial spanning tree model and the to-be-matched spanning tree model have an intersection, the overlapping nodes of the historical test cases where the initial spanning tree model and the to-be-matched spanning tree model have an intersection with the to-be-matched spanning tree model, and the leaf nodes of the test cases where the initial spanning tree model and the to-be-matched spanning tree model have an intersection, etc.

[0047] In the embodiments of the present invention, the initial spanning tree model and the to-be-matched spanning tree model can be matched to determine the intersection of the initial spanning tree model and the to-be-matched spanning tree model, and then the intersection test case data is determined according to the intersection of the initial spanning tree model and the to-be-matched spanning tree model.

[0048] S140. Determine target test cases based on the intersection test case data and the use case weights matching the intersection test case data.

[0049] Among them, the target test cases can be test cases that meet the test requirements, that is, the target test cases are a set of test cases that can fully cover the data to be tested.

[0050] In the embodiments of the present invention, historical test cases matching the intersection test case data can be first determined, and then the use case weights of the historical test cases matching the intersection test case data can be determined. Then, based on a preset algorithm, data processing is performed on the intersection test case data and the use case weights matching the intersection test case data to obtain target test cases. Optionally, the preset algorithm can include multi-objective optimization algorithms and NP-Hard approximate solution algorithms, etc. As long as it can screen out target test cases that fully cover the data to be tested and ensure the minimum execution cost, the embodiments of the present invention do not limit the preset algorithm.

[0051] The embodiments of the present invention can uniformly model historical test cases and data to be tested, reflect the code coverage of each historical test case and the data to be tested through intersection test case data, and use case weights to reflect the execution cost of test cases, and intelligently make decisions for testers on the set of test cases with the lowest cost for regression testing.

[0052] The technical solution of this embodiment obtains test case association data including historical test cases, data to be tested, and use case weights, then generates an initial spanning tree model according to the historical test cases, and generates a to-be-matched spanning tree model according to the data to be tested to determine the intersection test case data between the initial spanning tree model and the to-be-matched spanning tree model. Then, target test cases are determined based on the intersection test case data and the use case weights matching the intersection test case data. In this solution, both historical test cases and data to be tested are transformed into tree models, which can intuitively establish the association relationship between test requirements and historical test cases, facilitating the display and storage of model-based historical test cases and data to be tested. And the determined intersection test case data can accurately reflect the characteristics of the test cases required to fully cover the to-be-matched spanning tree model. Therefore, determining target test cases based on the intersection test case data and the use case weights reflecting the execution cost of historical test cases can screen out test cases with the lowest test cost on the premise of ensuring full coverage of test requirements, avoid redundancy in the selection of test cases, thereby improving the execution efficiency of regression testing, solving the problems of high labor cost, large selection error, unsatisfactory coverage, and high execution cost existing in the manual selection of test cases in the prior art, saving the labor cost of selecting test cases, reducing the selection error caused by manual selection of test cases, and improving the execution efficiency of regression testing on the premise of ensuring full coverage of test cases.

[0053] Example 2

[0054] Figure 2 is a flowchart of a test case determination method provided in Example 2 of the present invention. This embodiment is specific based on the above embodiment. In this embodiment, specific optional implementation manners of generating an initial spanning tree model according to historical test cases and generating a to-be-matched spanning tree model according to data to be tested are given. Correspondingly, as Figure 2 shown, the method includes the following operations:

[0055] S210. Obtain test case association data.

[0056] In an optional embodiment of the present invention, obtaining test case association data may include: obtaining historical execution data of historical test cases; determining execution time data and execution complexity data of historical test cases according to the historical execution data; and determining case weights according to the execution time data and the execution complexity data.

[0057] Among them, the historical execution data may be data reflecting the historical test situation of historical test cases. The execution time data may be used to characterize the time-consuming degree of historical test cases during historical tests. The execution complexity data may be used to characterize the test complexity of historical test cases during historical tests.

[0058] In the embodiment of the present invention, historical execution data of historical test cases during multiple historical tests may be obtained first, and then the historical execution data may be parsed to determine the execution time and running complexity of historical test cases during multiple historical tests. Then, execution time data is determined according to the execution time of historical test cases during multiple historical tests, and execution complexity data is determined according to the running complexity of historical test cases during multiple historical tests. Exemplarily, the average value of the execution times during multiple historical tests or the longest execution time during multiple historical tests may be used as the execution time data of historical test cases, and the average value of the running complexities during multiple historical tests or the maximum running complexity during multiple historical tests may be used as the execution complexity data of historical test cases. After obtaining the execution time data and execution complexity data of historical test cases, case weights may be configured for historical test cases according to the execution time data and the execution complexity data.

[0059] Optionally, during the execution of the historical regression test phase, the execution time and running complexity of each test case may be recorded, and then weights may be assigned to each test case in combination with the preparation time or preparation complexity of the preconditions required for each test case to execute.

[0060] S220. Generate an initial spanning tree model based on historical test cases, and generate a to-be-matched spanning tree model based on the data to be tested.

[0061] In an optional embodiment of the present invention, S220 may specifically include:

[0062] S221. Obtain a code coverage report of historical test cases through code coverage detection technology.

[0063] Among them, code coverage detection technology can be used to detect the proportion and degree of source code being tested. The code coverage report can be the test result of code coverage testing.

[0064] In the embodiments of the present invention, when deploying the application or system to be tested in the test environment, the code coverage of historical test cases during historical regression testing can be detected based on code coverage detection technology to generate a code coverage report. Exemplarily, code coverage detection tools (such as Jacoco or Cobertura, etc.) can be used for instrumentation, so that when each test case is executed, the code coverage report of the test case can be directly obtained.

[0065] S222. Generate an initial spanning tree model according to the spanning tree mapping rule and the code coverage report.

[0066] Among them, the spanning tree mapping rule can be a rule for generating the required tree structure, and is used to generate the initial spanning tree model and the to-be-matched spanning tree model.

[0067] In the embodiments of the present invention, the spanning tree mapping rule can be determined according to the construction requirements of the tree structure, and then the code coverage report can be mapped according to the spanning tree mapping rule to generate an initial spanning tree model. Since the code coverage report includes the information required to construct the initial spanning tree model, the initial spanning tree model can be automatically constructed according to the spanning tree mapping rule. Among them, the tree structure of each historical test case has a corresponding use case weight.

[0068] Exemplarily, key information such as system name, package name, class name, method name, and branches in the code coverage report can be extracted according to the spanning tree mapping rule, so as to convert the code coverage report into a tree structure and obtain the initial spanning tree model. The specific data content extracted by the spanning tree mapping rule in the embodiments of the present invention is not limited.

[0069] In an optional embodiment of the present invention, before generating the initial spanning tree model according to the spanning tree mapping rule and the code coverage report, it may include: obtaining the data of the relationship between spanning tree levels and the data of the sorting of nodes in the same layer; generating the spanning tree mapping rule according to the data of the relationship between spanning tree levels and the data of the sorting of nodes in the same layer.

[0070] Among them, the tree hierarchical relationship data can be data representing the sorting rules of nodes at different levels in the tree structure. The same-level node sorting data can be data representing the sorting rules of nodes at the same level in the tree structure.

[0071] In an embodiment of the present invention, the tree hierarchical relationship data and the same-level node sorting data can be determined according to the data search efficiency of the tree structure, and then the node arrangement rules of the required tree structure can be determined according to the generated tree hierarchical relationship data and the same-level node sorting data, so as to determine the generated tree mapping rules according to the node arrangement rules and the node intervals.

[0072] Exemplarily, since the generation principles of the initial generated tree model and the to-be-matched generated tree model are the same, taking the tree structure of the initial generated tree model as an example for illustration, the initial generated tree model can include multiple levels. The root node can be the system name, the second-level node is the package name of the project code included under the system name in the root node, the third-level node is the class name matched by the package name of each project code, the fourth level is the method name included in each class, and the fifth level is the branch name plus the line number of the code matched by each method name. It should be noted that all the child nodes of each initial generated tree model in the forest structure are in a certain order from left to right, arranged in alphabetical and / or numerical order, with letters before numbers. If the first letters are the same, they are arranged according to the second letter, and so on. The initial generated tree model of the finally generated forest structure can be seen in Figure 3 . It can be understood that Figure 3 the Chinese characters in

[0073] S223. Generate a to-be-matched generated tree model according to the generated tree mapping rule and the to-be-tested data.

[0074] In an embodiment of the present invention, the to-be-tested data can be mapped according to the generated tree mapping rule to generate a to-be-matched generated tree model.

[0075] Exemplarily, the system name, package name, class name, method name, and branch, etc. of the to-be-tested function code or the changed code (for the patch code for certain changes and modification problems, the corresponding changed code set can be directly obtained through the functions of code management tools such as git or CVS, etc.) can be extracted according to the generated tree mapping rule, so as to automatically convert the changed code or the to-be-tested function code into a tree structure to obtain a to-be-matched generated tree model. Assume that the generated to-be-matched generated tree model only has an intersection with Figure 3 the initial generated tree model 1 in Figure 3 The nodes of the to-be-matched generated tree model are represented by dotted lines and marked in the initial generated tree model in Figure 4 .

[0076] S230. Determine the intersection test case data of the initial spanning tree model and the spanning tree model to be matched.

[0077] In an alternative embodiment of the present invention, determining the intersection test case data of the initial spanning tree model and the spanning tree model to be matched may include: determining the target leaf nodes of the currently to-be-matched spanning tree model; matching the initial spanning tree model with the target leaf nodes to determine the intersection test case data that matches the currently to-be-matched spanning tree model.

[0078] Among them, the target leaf nodes may be all the leaf nodes of the currently to-be-matched spanning tree model.

[0079] In an embodiment of the present invention, the currently to-be-matched spanning tree model may be parsed to determine all the leaf nodes of the currently matched spanning tree model, and then all the obtained leaf nodes may be used as the target leaf nodes. Thus, the leaf nodes of the initial spanning tree model are matched with the target leaf nodes of the currently to-be-matched spanning tree model. If there is an intersection between the leaf nodes of the initial spanning tree model and the target leaf nodes, the intersection test case data that matches the currently to-be-matched spanning tree model is determined according to the intersection. If there is no intersection between the leaf nodes of the initial spanning tree model and the target leaf nodes, no intersection test case data is generated.

[0080] S240. Determine the target test cases according to the intersection test case data and the case weights that match the intersection test case data.

[0081] In an alternative embodiment of the present invention, determining the target test cases according to the intersection test case data and the case weights that match the intersection test case data may include: determining the number of intersection nodes that match the currently to-be-matched spanning tree model according to the intersection test case data; determining the local coverage test cases according to the number of intersection nodes that match the currently to-be-matched spanning tree model and the case weights; removing the local coverage test cases in the currently to-be-matched spanning tree model, and returning to perform the operation of determining the target leaf nodes of the currently to-be-matched spanning tree model until the target leaf nodes of the currently to-be-matched spanning tree model are empty.

[0082] Among them, the number of intersection nodes can be the number of overlapping nodes between each historical test case where the initial generation tree model and the generation tree model to be matched have an intersection and the current generation tree model to be matched. For example, the historical test cases where the initial generation tree model and the generation tree model to be matched have an intersection are historical test case 1 and historical test case 2. The number of overlapping nodes between historical test case 1 and the current generation tree model to be matched is 2, and the number of overlapping nodes between historical test case 2 and the current generation tree model to be matched is 3. Then, the number of intersection nodes of historical test case 1 matched with the current generation tree model to be matched is 2, and the number of intersection nodes of historical test case 2 matched with the current generation tree model to be matched is 3. The local coverage test case can be a historical test case that covers the current generation tree model to be matched, determined according to the number of intersection nodes matched with the current generation tree model to be matched and the use case weight.

[0083] In the embodiments of the present invention, the overlapping nodes between each test case where the initial generation tree model and the current generation tree model to be matched have an intersection can be determined according to the intersection test case data, and then the number of intersection nodes where the overlapping nodes in the above-mentioned each test case are matched with the current generation tree model to be matched can be counted. Further, the use case weight of the test case matched with the intersection node can be determined, and then according to the number of intersection nodes of the above-mentioned each test case and the use case weight of the test case matched with the intersection node, the local coverage test case can be determined from at least one test case matched with the intersection node. After obtaining the local coverage test case, the local coverage test case in the current generation tree model to be matched is removed to obtain the updated current generation tree model to be matched, and a new local coverage test case is determined according to the updated current generation tree model to be matched (the method for determining the local coverage test case has been described in this part and will not be elaborated here). When the target leaf node of the generation tree model to be matched is empty after removing the new local coverage test case, the process can be stopped. If the target leaf node of the generation tree model to be matched is not empty, return to execute the operation of determining the target leaf node of the current generation tree model to be matched until the target leaf node of the generation tree model to be matched is empty.

[0084] In a specific example, assume that the test cases where the initial generation tree model intersects with the currently to-be-matched generation tree model are Test Case 1, Test Case 2, and Test Case 3. After obtaining each test case where the initial generation tree model intersects with the currently to-be-matched generation tree model, further determine the number of overlapping nodes between Test Case 1, Test Case 2, and Test Case 3 and the currently to-be-matched generation tree model respectively, that is, respectively determine the number of intersection nodes between Test Case 1, Test Case 2, and Test Case 3 and the currently to-be-matched generation tree model. Then determine the use case weight a of Test Case 1, the use case weight b of Test Case 2, and the use case weight c of Test Case 3, so as to further select a test case from Test Case 1, Test Case 2, and Test Case 3 as the local coverage test case according to the number of intersection nodes between Test Case 1 and the currently to-be-matched generation tree model, the use case weight a, the number of intersection nodes between Test Case 2 and the currently to-be-matched generation tree model, the use case weight b, the number of intersection nodes between Test Case 3 and the currently to-be-matched generation tree model, and the use case weight c.

[0085] In an alternative embodiment of the present invention, the number of intersection nodes may include the number of intersection leaf nodes and the number of intersection global nodes. Determining the local coverage test case according to the number of intersection nodes that match the currently to-be-matched generation tree model and the use case weight may include: calculating the first weight density data according to the number of intersection leaf nodes that match the currently to-be-matched generation tree model and the use case weight; when the first weight density data is the same as that of at least two historical test cases, calculating the second weight density data according to the number of intersection global nodes that match the currently to-be-matched generation tree model and the use case weight; and determining the local coverage test case according to the second weight density data.

[0086] Among them, the number of intersection leaf nodes may be the number of leaf nodes where each historical test case where the initial generation tree model intersects with the currently to-be-matched generation tree model overlaps with the currently to-be-matched generation tree model respectively. The number of intersection global nodes may be the number of all nodes where each historical test case where the initial generation tree model intersects with the currently to-be-matched generation tree model overlaps with the currently to-be-matched generation tree model respectively. The first weight density data may be data determined according to the number of intersection leaf nodes that match the currently to-be-matched generation tree model and the use case weight, and is used to determine the local coverage test case. The second weight density data may be data determined according to the number of intersection global nodes that match the currently to-be-matched generation tree model and the use case weight, and is used to determine the local coverage test case.

[0087] In an embodiment of the present invention, it is possible to determine the number of leaf nodes that each historical test case where the initial spanning tree model intersects with the currently to-be-matched spanning tree model coincides with the currently to-be-matched spanning tree model based on the intersection test case data, that is, to determine the intersection leaf node numbers of each historical test case in the initial spanning tree model that intersects with the currently to-be-matched spanning tree model. Furthermore, calculate the ratio of the intersection leaf node number of each historical test case to the use case weight of the corresponding historical test case, or the ratio of the use case weight of each historical test case to the corresponding intersection leaf node number, to obtain the first weight density data of each historical test case in the initial spanning tree model that intersects with the currently to-be-matched spanning tree model. After obtaining the first weight density data of each historical test case, the first weight density data of each historical test case can be compared. If the first weight density data of at least two historical test cases are the same, it is necessary to further determine the number of all nodes that each historical test case where the initial spanning tree model intersects with the currently to-be-matched spanning tree model coincides with the currently to-be-matched spanning tree model based on the intersection test case data, that is, to determine the intersection global node numbers of each historical test case in the initial spanning tree model that intersects with the currently to-be-matched spanning tree model. Then calculate the ratio of the intersection global node number of each historical test case to the use case weight of the corresponding historical test case, or the ratio of the use case weight of each historical test case to the corresponding intersection global node number, to obtain the second weight density data of each historical test case in the initial spanning tree model that intersects with the currently to-be-matched spanning tree model. Furthermore, compare the second weight density data of each historical test case, determine the minimum ratio of the use case weight of each historical test case to the corresponding intersection global node number, and use the historical test case that matches the minimum ratio as the local coverage test case, or determine the ratio of the intersection global node number of each historical test case to the use case weight of the corresponding historical test case, and use the historical test case that matches the maximum ratio as the local coverage test case.

[0088] If the first weight density data of any two historical test cases are different, determine the minimum ratio of the use case weight of each historical test case to the corresponding intersection leaf node number, and use the historical test case corresponding to the minimum ratio as the local coverage test case, or determine the maximum ratio of the intersection leaf node number of each historical test case to the use case weight of the corresponding historical test case, and use the historical test case corresponding to the maximum ratio as the local coverage test case.

[0089] In a specific example, the determination logic of the target test case can be illustrated by set covering. Given the target set g and the candidate set space S{s1, s2..., s n}, where n is the number of set elements, as long as the subsets selected from S It is considered that C can cover g. Assume that each element in the candidate set space S has weights w(s1), w(s2)... w(s n ), and it is necessary to find a set C{s1, s2..., s x} in all the sets that can cover g on S such that the sum of the weight values of all elements in C is the smallest, s i ∈C, and determining the target test case is equivalent to determining the set with the smallest use case weight in at least one initial spanning tree model to cover the to-be-matched spanning tree model.

[0090] Specifically, the set composed of n initial spanning tree models can be denoted as S, s i can be understood as the initial spanning tree model of the i-th historical test case (i is greater than or equal to 1 and less than or equal to n), and the to-be-matched spanning tree model is denoted as g. At this time, the determination of the target test case is equivalent to a weighted minimum set cover problem. Since the weighted minimum set cover problem is an NP-hard problem and an exact solution cannot be obtained within polynomial time, an existing approximation algorithm with greedy thinking (abbreviated as the greedy algorithm) can be selected to solve it, and it is optimized in combination with the characteristics of regression testing and the initial spanning tree model. The specific idea is: First, traverse and select an element s j from the set space S and put it into the result set C, requiring that s j is the initial spanning tree model of the historical test case that has an intersection with the leaf nodes of g and has the smallest first weight density data. Then, make a difference set between g and s j , and use (g - s j ) as the new g, and repeat the previous two steps until the difference set is empty. For example, the first weight density data can be calculated according to the formula , where w(s j ) represents the use case weight corresponding to the initial spanning tree model s j of the historical test case, and LeavesOf(s j ∩g) represents the number of intersection leaf nodes between the initial spanning tree model s j of the historical test case and the current g. If the first weight density data of the initial spanning tree models of multiple historical test cases is the same, by comparing the second weight density data of the initial spanning tree models of multiple historical test cases, the initial spanning tree model of the historical test case with the smallest second weight density data among the initial spanning tree models of multiple historical test cases is added to C, and the historical test cases corresponding to the initial spanning tree models of the historical test cases finally included in C are used as the target test cases. For example, the second weight density data can be calculated according to the formula , where NodesOf(s j ∩g) represents the number of intersection nodes between the initial spanning tree model sj The number of global nodes in the intersection with the current g.

[0091] Figure 5 It is a simple logic diagram of a test case determination method provided in the second embodiment of the present invention. As Figure 5 shown, it is possible to first obtain execution time data and execution complexity data, and then determine the use case weight based on the execution time data and execution complexity data. Furthermore, obtain the Jacoco code coverage report of historical test cases, establish an initial spanning tree model according to the spanning tree mapping rule and the Jacoco code coverage report, and further establish a to-be-matched spanning tree model according to the spanning tree mapping rule and the data to be tested, so as to use the greedy algorithm to calculate the set of regression test cases (target test cases) with the smallest cost for full coverage.

[0092] Figure 6 It is a schematic diagram of a minimum coverage spanning tree provided in the second embodiment of the present invention. Figure 6 It includes the initial spanning tree models of 3 historical test cases. The initial spanning tree model of historical test case 1 is composed of system 1, project package 1, class 1, method 1, method 2, branch if-1, and branch for-1. The initial spanning tree model of historical test case 2 is composed of system 1, project package 1, class 1, method 2, and branch if-2. The initial spanning tree model of historical test case 3 is composed of system 1, project package 1, class 2, method 3, project package 2, class 3, method 4, and branch else-2. The initial spanning tree models of historical test case 1, historical test case 2, and historical test case 3 completely cover the to-be-matched spanning tree model. Although the initial spanning tree model of historical test case 3 also covers the node - branch else-112 that does not belong to the to-be-matched spanning tree model, it can still be considered that the set composed of these three test cases is a set that can cover the to-be-matched spanning tree model. Further, take Figure 6Taking historical test case 1 and historical test case 3 as examples to illustrate the calculation and selection of the first weight density data. Assume that the case weights of historical test case 1 and historical test case 3 are both 28. Since the number of intersection leaf nodes of historical test case 1 is 2, the first weight density data of historical test case 1 is 28 / 2 = 14. The number of intersection leaf nodes of historical test case 2 is 1, and the first weight density data of historical test case 2 is 28 / 1 = 28. The number of intersection leaf nodes of historical test case 3 is 1, and the first weight density data of historical test case 3 is 28 / 1 = 28. When historical test case 1 and historical test case 3 are compared together, historical test case 1 will be preferentially selected because among the test cases with the same execution cost, the coverage rate of historical test case 1 is the highest. Similarly, the one with the lowest average execution cost under the premise of ensuring test coverage will be preferentially selected. In addition, if the first weight density data of historical test case 1 and other historical test cases are the same, it is necessary to calculate the second weight density data of historical test case 1. Since the leaf node set of each historical test case is completely corresponding to the initial generation tree model, when there is an intersection between the initial generation tree model of the test case and the to-be-matched generation tree model, all the nodes passed by the path from the leaf node back to the root node of the initial generation tree model of the test case with the intersection can be marked as the intersection global nodes of this historical test case. The marking results of the intersection global nodes in the initial generation tree models of historical test case 1, historical test case 2, and historical test case 3 can be respectively referred to Figure 7 , Figure 8 , and Figure 9 . Since the number of intersection global nodes of historical test case 1 is 7, the second weight density data of historical test case 1 is 28 / 7 = 4. The number of intersection global nodes of historical test case 2 is 5, so the second weight density data of historical test case 2 is 28 / 5. The number of intersection global nodes of historical test case 3 is 4, so the second weight density data of historical test case 3 is 28 / 4 = 7.

[0093] In the embodiments of the present invention, the test requirements and test cases are uniformly modeled. On the basis of considering indicators such as the coverage rate of test cases for test requirements, the execution cost and quantity of test cases, an optimized greedy algorithm is used to calculate the test cases required for regression testing. For different regression test requirements, considering both test coverage and test case execution cost, a set with the minimum execution cost of test cases is determined more efficiently, quickly, and accurately, effectively improving the accuracy and efficiency of regression test case selection and execution, and further improving the quality and standardization of testing.

[0094] This solution unifies and models the code coverage report of historical test cases and the code sets of regression test requirements (changed code and / or code to be tested for functions), which very intuitively reflects the association relationships among test requirements, among test cases, and between test cases and requirements. At the same time, it not only avoids the huge space and time complexity of directly batch-processing the code coverage report or code, but also facilitates the intuitive display and storage of the main content of code coverage in a model-based manner. At the same time, it also lays a data structure foundation for subsequent further intelligent and accurate calculations.

[0095] Intelligently screen out the weighted minimum regression test case set for different test requirements. Compared with the existing regression test case screening methods and tools, relying on the tree model, based on an approximate solution of the existing NP-Hard problem - the greedy thought algorithm, and optimized and improved in combination with the characteristics of regression testing and the tree model itself. When calculating, on the premise of fully considering the complete coverage of test requirements by test cases, the time and preparation costs of test cases are minimized. It intelligently makes the screening of the regression test case set for testers, rather than just providing some screening reference indicators or objective data for users to choose according to their own judgments and experiences.

[0096] When analyzing and modeling test cases, it is based on an accurate code coverage report. Therefore, it is more accurate than manually selecting according to the regression strategy or manually analyzing test requirements and the association degree with test cases, greatly reducing the randomness and error of regression test case selection, avoiding situations such as a large number of repeated and redundant cases being executed, incomplete coverage of regression test cases, and high execution costs of regression test cases caused by manual selection, better saving manpower and time costs, and improving the accuracy of testing.

[0097] When calculating the minimum test case set, on the premise of ensuring the coverage rate, not only the number of test cases is considered, but also factors such as the complex environment preparation that each test case may require and the time cost of execution are comprehensively considered for intelligent decision-making.

[0098] The technical solution of this embodiment obtains test case associated data, and then obtains the code coverage report of historical test cases through code coverage detection technology, and generates an initial spanning tree model according to the spanning tree mapping rule and the code coverage report. Then, a to-be-matched spanning tree model is generated according to the spanning tree mapping rule and the data to be tested. Further, the intersection test case data of the initial spanning tree model and the to-be-matched spanning tree model is determined. Thus, the target test case is determined according to the intersection test case data and the use case weight matching the intersection test case data. In this solution, both historical test cases and data to be tested are converted into tree models, which can intuitively establish the association relationship between test requirements and historical test cases, facilitating the display and storage of model-based historical test cases and data to be tested. And the determined intersection test case data can accurately reflect the characteristics of the test cases required to fully cover the to-be-matched spanning tree model. Therefore, determining the target test case according to the intersection test case data and the use case weight reflecting the execution cost of test cases during historical testing can screen out the test cases with the lowest test cost on the premise of ensuring full coverage of test requirements, avoiding redundancy in the selection of test cases, thereby improving the execution efficiency of regression testing, solving the problems of high labor cost, large selection error, unsatisfactory coverage, and high execution cost existing in the artificial selection of test cases in the prior art, being able to save the labor cost of selecting test cases, reduce the selection error caused by artificial selection of test cases, and improve the execution efficiency of regression testing on the premise of ensuring full coverage of test cases.

[0099] It should be noted that any permutation and combination of the technical features in the above embodiments also fall within the protection scope of the present invention.

[0100] Embodiment III

[0101] Figure 10 is a schematic diagram of a test case determination device provided in Embodiment III of the present invention. As Figure 10 shown, the device includes: a data acquisition module 310, a tree model generation module 320, a first data determination module 330, and a second data determination module 340, where:

[0102] The data acquisition module 310 is configured to acquire test case associated data; where the test case associated data includes historical test cases, data to be tested, and use case weights;

[0103] The tree model generation module 320 is configured to generate an initial spanning tree model according to historical test cases and generate a to-be-matched spanning tree model according to the data to be tested;

[0104] The first data determination module 330 is configured to determine the intersection test case data of the initial spanning tree model and the to-be-matched spanning tree model;

[0105] The second data determination module 340 is configured to determine target test cases according to the intersection test case data and the use case weights matching the intersection test case data.

[0106] The technical solution of this embodiment obtains test case association data including historical test cases, data to be tested, and use case weights, then generates an initial spanning tree model according to the historical test cases, and generates a to-be-matched spanning tree model according to the data to be tested to determine the intersection test case data between the initial spanning tree model and the to-be-matched spanning tree model, so as to determine target test cases according to the intersection test case data and the use case weights matching the intersection test case data. In this solution, both the historical test cases and the data to be tested are converted into tree models, which can intuitively establish the association relationship between test requirements and historical test cases, facilitating the display and storage of the modeled historical test cases and the data to be tested. The determined intersection test case data can accurately reflect the characteristics of the test cases required to fully cover the to-be-matched spanning tree model. Therefore, determining target test cases according to the intersection test case data and the use case weights reflecting the use case execution cost during historical testing can screen out the test cases with the lowest test cost while ensuring full coverage of test requirements, avoiding redundancy in the selection of test cases, thereby improving the execution efficiency of regression testing, solving the problems of high labor cost, large selection error, unsatisfactory coverage, and high execution cost in the existing technology of manually selecting test cases, being able to save the labor cost of selecting test cases, reduce the selection error caused by manually selecting test cases, and improve the execution efficiency of regression testing on the premise of ensuring full coverage of test cases.

[0107] Optionally, the data acquisition module 310 is specifically configured to obtain the historical execution data of the historical test cases; determine the execution time data and the execution complexity data of the historical test cases according to the historical execution data; and determine the use case weights according to the execution time data and the execution complexity data.

[0108] Optionally, the tree model generation module 320 is specifically configured to obtain the code coverage report of the historical test cases through code coverage detection technology; generate the initial spanning tree model according to the spanning tree mapping rules and the code coverage report; and generate the to-be-matched spanning tree model according to the spanning tree mapping rules and the data to be tested.

[0109] Optionally, the test case determination device further includes a spanning tree mapping rule generation model, configured to obtain the data of the relationship between spanning tree levels and the data of the sorting of nodes at the same level; and generate the spanning tree mapping rules according to the data of the relationship between spanning tree levels and the data of the sorting of nodes at the same level.

[0110] Optionally, the first data determination module 330 is specifically configured to determine a target leaf node of the currently to-be-matched spanning tree model; match the initial spanning tree model with the target leaf node to determine intersection test case data that matches the currently to-be-matched spanning tree model.

[0111] Optionally, the second data determination module 340 is specifically configured to determine the number of intersection nodes that match the currently to-be-matched spanning tree model according to the intersection test case data; determine local coverage test cases according to the number of intersection nodes that match the currently to-be-matched spanning tree model and the use case weight; remove the local coverage test cases in the currently to-be-matched spanning tree model, and return to perform the operation of determining the target leaf node of the currently to-be-matched spanning tree model until the target leaf node of the currently to-be-matched spanning tree model is empty.

[0112] Optionally, the second data determination module 340 is specifically configured to calculate first weight density data according to the number of intersection leaf nodes of the currently to-be-matched spanning tree model and the use case weight; when the first weight density data is the same as that of at least one historical test case, calculate second weight density data according to the number of intersection global nodes that match the currently to-be-matched spanning tree model and the use case weight; determine the local coverage test cases according to the second weight density data.

[0113] The above test case determination device can execute the test case determination method provided in any embodiment of the present invention, and has corresponding functional modules and beneficial effects for executing the method. For technical details not described in detail in this embodiment, reference can be made to the test case determination method provided in any embodiment of the present invention.

[0114] Since the above-introduced test case determination device is a device that can execute the test case determination method in the embodiment of the present invention, based on the test case determination method introduced in the embodiment of the present invention, those skilled in the art can understand the specific implementation manners and various variations of the test case determination device in this embodiment. Therefore, the specific implementation of how the test case determination device implements the test case determination method in the embodiment of the present invention will not be described in detail here. As long as the device adopted by those skilled in the art to implement the test case determination method in the embodiment of the present invention belongs to the scope to be protected by this application.

[0115] Embodiment 4

[0116] Figure 11 It is a schematic structural diagram of an electronic device provided in Embodiment 4 of the present invention. Figure 11 A block diagram of an electronic device 412 suitable for use in implementing embodiments of the present invention is shown. Figure 11The illustrated electronic device 412 is merely an example and should not impose any limitation on the functionality and usage scope of the embodiments of the present invention.

[0117] As Figure 11 shown, the electronic device 412 appears in the form of a general-purpose computing device. The components of the electronic device 412 may include, but are not limited to: one or more processors 416, a storage device 428, and a bus 418 that connects different system components (including the storage device 428 and the processor 416).

[0118] The bus 418 represents one or more of several types of bus architectures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of the various bus architectures. By way of example, these architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, MicroChannel Architecture (MCA) bus, Enhanced ISA bus, Video Electronics Standards Association (VESA) local bus, and Peripheral Component Interconnect (PCI) bus.

[0119] The electronic device 412 typically includes a variety of computer system-readable media. These media can be any available media accessible by the electronic device 412, including volatile and non-volatile media, removable and non-removable media.

[0120] The storage device 428 may include computer system-readable media in the form of volatile memory, such as RAM (Random Access Memory) 430 and / or cache memory 432. The electronic device 412 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, a storage system 434 may be used to read and write non-removable, non-volatile magnetic media ( Figure 11 not shown, typically referred to as a "hard disk drive"). Although Figure 11Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (such as a "floppy disk") and an optical disk drive for reading and writing to a removable non-volatile optical disk (such as a Compact Disc-ReadOnly Memory (CD-ROM), Digital Video Disc-Read Only Memory (DVD-ROM), or other optical media) can be provided. In these cases, each drive can be connected to the bus 418 through one or more data medium interfaces. The storage device 428 can include at least one program product having a set (such as at least one) of program modules configured to perform the functions of the embodiments of the present invention.

[0121] A program 436 having a set (at least one) of program modules 426 can be stored, for example, in the storage device 428. Such program modules 426 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. The implementation of a network environment may be included in each or some combination of these examples. The program modules 426 generally execute the functions and / or methods in the embodiments described in the present invention.

[0122] The electronic device 412 can also communicate with one or more external devices 414 (such as a keyboard, a pointing device, a camera, a display 424, etc.), and can also communicate with one or more devices that enable a user to interact with the electronic device 412, and / or communicate with any device that enables the electronic device 412 to communicate with one or more other computing devices (such as a network card, a modem, etc.). Such communication can be carried out through the I / O interface 422. Moreover, the electronic device 412 can also communicate with one or more networks (such as a Local Area Network (LAN), a Wide Area Network (WAN), and / or a public network, such as the Internet) through the network adapter 420. As shown in the figure, the network adapter 420 communicates with other modules of the electronic device 412 through the bus 418. It should be understood that although not shown in the figure, other hardware and / or software modules can be used in combination with the electronic device 412, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, Redundant Arrays of Independent Disks (RAID) systems, tape drives, and data backup storage systems, etc.

[0123] The processor 416 executes various functional applications and data processing by running programs stored in the storage device 428, such as implementing the test case determination method provided in the above embodiments of the present invention, including: obtaining test case associated data; wherein, the test case associated data includes historical test cases, data to be tested, and case weights; generating an initial generation tree model according to the historical test cases, and generating a to-be-matched generation tree model according to the data to be tested; determining the intersection test case data of the initial generation tree model and the to-be-matched generation tree model; and determining the target test cases according to the intersection test case data and the case weights matching the intersection test case data.

[0124] The technical solution of this embodiment obtains test case associated data including historical test cases, data to be tested, and case weights, and then generates an initial generation tree model according to the historical test cases, and generates a to-be-matched generation tree model according to the data to be tested, so as to determine the intersection test case data of the initial generation tree model and the to-be-matched generation tree model, and thus determine the target test cases according to the intersection test case data and the case weights matching the intersection test case data. In this solution, both the historical test cases and the data to be tested are converted into tree models, which can intuitively establish the association relationship between the test requirements and the historical test cases, facilitating the display and storage of the modeled historical test cases and the data to be tested. And the determined intersection test case data can accurately reflect the characteristics of the test cases required to fully cover the to-be-matched generation tree model. Therefore, determining the target test cases according to the intersection test case data and the case weights reflecting the case execution cost during historical testing can screen out the test cases with the lowest test cost on the premise of ensuring full coverage of the test requirements, avoiding redundancy in the selection of test cases, thereby improving the execution efficiency of regression testing, solving the problems of high labor cost, large selection error, unsatisfactory coverage, and high execution cost existing in the prior art when manually selecting test cases, being able to save the labor cost of selecting test cases, reduce the selection error caused by manually selecting test cases, and improve the execution efficiency of regression testing on the premise of ensuring full coverage of test cases.

[0125] Embodiment Five

[0126] Embodiment Five of the present invention further provides a computer storage medium storing a computer program, and the computer program is used to execute the test case determination method according to any one of the above embodiments of the present invention when executed by a computer processor, including: obtaining test case associated data; wherein, the test case associated data includes historical test cases, data to be tested, and case weights; generating an initial generation tree model according to the historical test cases, and generating a to-be-matched generation tree model according to the data to be tested; determining the intersection test case data of the initial generation tree model and the to-be-matched generation tree model; and determining the target test cases according to the intersection test case data and the case weights matching the intersection test case data.

[0127] The computer storage medium of the embodiment of the present invention may adopt any combination of one or more computer-readable media. The computer-readable media may be computer-readable signal media or computer-readable storage media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples (non-exhaustive list) of the computer-readable storage medium include: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM) or a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program may be used by or in combination with an instruction execution system, apparatus, or device.

[0128] The computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable medium other than the computer-readable storage medium, and the computer-readable medium may send, propagate, or transmit a program for use by or in combination with an instruction execution system, apparatus, or device.

[0129] The program code contained on the computer-readable medium may be transmitted by any suitable medium, including but not limited to wireless, wire, optical fiber, radio frequency (RF), etc., or any suitable combination of the above.

[0130] Computer program code for performing the operations of the present invention may be written in one or more programming languages or combinations thereof, including object-oriented programming languages such as Java, Smalltalk, C++, as well as conventional procedural programming languages such as the "C" language or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, executed as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).

[0131] Note that the above is only the preferred embodiment of the present invention and the technical principles applied. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and various obvious changes, re-adjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments. Without departing from the concept of the present invention, more other equivalent embodiments may be included, and the scope of the present invention is determined by the scope of the appended claims.

Claims

1. A test case determination method, characterized in that, Including: Obtain test case associated data; wherein, the test case associated data includes historical test cases, data to be tested, and case weights; Generate an initial spanning tree model according to the historical test cases, and generate a to-be-matched spanning tree model according to the data to be tested; Determine the intersection test case data between the initial spanning tree model and the to-be-matched spanning tree model; Determine target test cases according to the intersection test case data and the case weights matching the intersection test case data; Wherein, the determining the intersection test case data between the initial spanning tree model and the to-be-matched spanning tree model includes: Determine the target leaf nodes of the current to-be-matched spanning tree model; Match the initial spanning tree model with the target leaf nodes to determine the intersection test case data matching the current to-be-matched spanning tree model; Wherein, the determining target test cases according to the intersection test case data and the case weights matching the intersection test case data includes: Determine the number of intersection nodes matching the current to-be-matched spanning tree model according to the intersection test case data; Determine local coverage test cases according to the number of intersection nodes matching the current to-be-matched spanning tree model and the case weights; Remove the local coverage test cases in the current to-be-matched spanning tree model, and return to perform the operation of determining the target leaf nodes of the current to-be-matched spanning tree model until the target leaf nodes of the current to-be-matched spanning tree model are empty.

2. The method according to claim 1, characterized in that, The obtaining the test case associated data includes: Obtain the historical execution data of the historical test cases; Determine the execution time data and execution complexity data of the historical test cases according to the historical execution data; Determine the case weights according to the execution time data and the execution complexity data.

3. The method according to claim 1, characterized in that The generating an initial spanning tree model according to the historical test cases and generating a to-be-matched spanning tree model according to the data to be tested includes: Obtain the code coverage report of the historical test cases through code coverage detection technology; Generate the initial spanning tree model according to the spanning tree mapping rules and the code coverage report; Generate the to-be-matched spanning tree model according to the spanning tree mapping rules and the data to be tested.

4. The method according to claim 3, characterized in that, Before generating the initial spanning tree model according to the spanning tree mapping rules and the code coverage report, it includes: Obtain the data of the relationship between spanning tree levels and the sorting data of nodes at the same level; Generate the spanning tree mapping rules according to the data of the relationship between spanning tree levels and the sorting data of nodes at the same level.

5. The method according to claim 1, characterized in that, The number of intersection nodes includes the number of intersection leaf nodes and the number of intersection global nodes. The determining local coverage test cases according to the number of intersection nodes matching the current to-be-matched spanning tree model and the case weights includes: Calculate the first weight density data according to the number of intersection leaf nodes matching the current to-be-matched spanning tree model and the case weights; When the first weight density data are the same as those of at least two historical test cases, the second weight density data is calculated according to the number of global nodes of the intersection matched with the current spanning tree model to be matched and the weight of the case; The local coverage test cases are determined according to the second weight density data.

6. A test case determination device, characterized in that, include: A data acquisition module is used to acquire test case related data; wherein the test case related data includes historical test cases, data to be tested and case weights; A tree model generation module, used to generate an initial spanning tree model according to the historical test case, and to generate a spanning tree model to be matched according to the data to be tested; A first data determination module, used to determine the intersection test case data of the initial spanning tree model and the spanning tree model to be matched; A second data determination module, configured to determine a target test case according to the intersection test case data and a case weight matching the intersection test case data; Among them, the first data determination module is specifically used to determine the target leaf node of the current spanning tree model to be matched; match the initial spanning tree model with the target leaf node to determine the intersection test case data that matches the current spanning tree model to be matched; Among them, the second data determination module is specifically used to determine the number of intersection nodes matching the current spanning tree model to be matched according to the intersection test case data; determine the local coverage test case according to the number of intersection nodes matching the current spanning tree model to be matched and the case weight; eliminate the local coverage test case in the current spanning tree model to be matched, and return to execute the operation of determining the target leaf node of the current spanning tree model to be matched until the target leaf node of the current spanning tree model to be matched is empty.

7. An electronic device, characterized in that, The electronic device comprises: one or more processors; A storage device for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the test case determination method as described in any one of claims 1-5.

8. A computer storage medium, on which a computer program is stored, characterized in that, When the program is executed by a processor, the test case determination method as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Measurement method and measurement device for test case coverage rate

    CN109976999A

  • Test case knowledge base construction method and device, electronic equipment and storage medium

    CN113704094A