Bipartite graph-based software test range determination method and related product

By building a binary graph model and a minimum vertex coverage algorithm, accurately identifying code changes and functional points, the efficiency and accuracy problems of software testing scope determination are solved, and automated and quantitative test scope optimization is achieved, and testing efficiency and quality are improved.

CN120492339APending Publication Date: 2025-08-15ABC FINANCIAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510582828.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-07
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

Existing software testing scope determination methods rely on manual experience, resulting in inefficient testing and waste of resources, making it difficult to accurately identify critical paths, resulting in lengthy test cycles and low quality.

Method used

By obtaining the variable files and line numbers between code versions, a binary graph model is constructed, and the call link relationship between the modified functions and function points is used to generate the minimum set of function points using the binary graph minimum vertex coverage algorithm, and the test range is determined according to the affected frequency.

Benefits of technology

It realizes automated and quantitative testing scope optimization, eliminates the subjectivity of manual judgment, avoids the waste of full testing resources, ensures priority verification of high-risk functions, and significantly improves testing efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120492339A_ABST
    Figure CN120492339A_ABST
Patent Text Reader

Abstract

The invention discloses a bipartite graph-based software test range determination method and a related product. According to the scheme, a change file between two version codes and a corresponding change line number are obtained; and determining a change function to which the change line number belongs. Function points corresponding to the change function are determined by calling the link, and the affected frequency of each function point is determined. And constructing a bipartite graph model according to the incidence relation between the change function and the function point. And solving the bipartite graph model to generate a minimum function point set. And sorting the minimum function point set according to the affected frequency, and generating a target test set with a test priority. According to the technical scheme, the code change analysis is combined with the bipartite graph model, the affected frequency is quantified by calling link analysis, and the test priority is sorted according to the affected frequency. And the test efficiency is obviously improved on the premise of ensuring the test sufficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of software testing technology, and in particular to a method for determining software testing scope based on a bipartite graph and related products. Background Art

[0002] With the increasing complexity and code size of software systems, software testing faces unprecedented challenges. Traditionally, testing scope is often determined based on manual experience. This approach is not only time-consuming and subjective, but can easily lead to missing critical paths. Using a full-scale testing approach can lead to a significant waste of testing resources, a problem that is particularly acute in large-scale systems.

[0003] With technological advancements, a variety of test optimization techniques have emerged. While static analysis tools can measure code test coverage, such as SonarQube, which generates coverage reports through code scanning, these tools are post-hoc assessments and cannot guide test case design during the test planning phase, making it difficult to avoid "ineffective testing." Some analysis methods based on code changes, while able to identify affected system functions, focus solely on static code differences and lack dynamic analysis capabilities. This often results in some critical paths not being included in the test scope, ultimately inflating test coverage and increasing the risk of defects escaping.

[0004] The limitations of existing technologies make it difficult for testing teams to efficiently and accurately determine the minimum test scope, which in turn leads to lengthy testing cycles and an imbalance between resource input and output, seriously affecting software delivery efficiency and quality. Summary of the Invention

[0005] Based on the above problems, this application provides a software test scope determination method and related products based on bipartite graphs, with the aim of improving the efficiency and accuracy of software test scope determination, thereby improving test efficiency while ensuring test adequacy.

[0006] The embodiments of this application disclose the following technical solutions:

[0007] In a first aspect, the present application provides a method for determining software test scope based on a bipartite graph, the method comprising:

[0008] Get the changed files and corresponding changed line numbers between the first version code and the second version code;

[0009] Determine the modified function to which the modified line number belongs based on the modified file;

[0010] Determine the function point corresponding to the modified function by calling the link, and determine the affected frequency of each function point; the affected frequency is the sum of the number of times different modified functions affect the same function point;

[0011] A bipartite graph model is constructed with the modification function as a first vertex set and the function point as a second vertex set; each edge in the edge set of the bipartite graph model represents an impact association established between the modification function and the function point through a call link;

[0012] Solving the bipartite graph model using a bipartite graph minimum vertex cover algorithm, generating a minimum set of function points covering all associated edges from the function points, so that at least one function point affected by each modification function is selected;

[0013] The minimum function point set is sorted according to the affected frequencies of the function points to generate a target test set with test priorities.

[0014] In an optional implementation, obtaining the changed files and corresponding changed line numbers between the first version of the code and the second version of the code includes:

[0015] Obtain the change information between the first version code and the second version code through the difference comparison command;

[0016] Based on the change information, the changed files and their corresponding changed line numbers are extracted.

[0017] In an optional implementation, determining the modified function to which the changed line number belongs based on the changed file includes:

[0018] Converting the changed file into an abstract syntax tree using a syntax parsing tool;

[0019] The abstract syntax tree is traversed to locate the modified function to which the changed line number belongs.

[0020] In an optional implementation, after traversing the abstract syntax tree to locate the modified function to which the changed line number belongs, the method further includes:

[0021] Determine whether the modified function is an interface layer function.

[0022] In an optional implementation, determining the functional point corresponding to the modified function by calling the link includes:

[0023] If the modified function is an interface layer function, obtaining a function route of the modified function through the abstract syntax tree, extracting a class route from the route annotation in the abstract syntax tree, concatenating the class route and the function route to form complete routing information, and determining a corresponding function point based on the complete routing information and a preset mapping relationship between routing and function points;

[0024] If the modified function is a non-interface layer function, recursively trace the upper-layer function that calls the modified function in the call link until the interface layer function is located; obtain the function route of the interface layer function through the abstract syntax tree, and extract the class route from the routing annotation in the abstract syntax tree, splice the class route and the function route to form complete routing information, and determine the corresponding function point based on the preset routing and function point mapping relationship according to the complete routing information.

[0025] In an optional implementation, the bipartite graph minimum vertex cover algorithm is the Hopcroft-Karp algorithm.

[0026] In an optional implementation, sorting the minimum function point set according to the affected frequencies of the function points to generate a target test set with test priorities includes:

[0027] The minimum function point set is sorted from high to low according to the affected frequency, a function point with a higher affected frequency has a higher test priority, and a minimum test set with priority is generated.

[0028] A second aspect of the present application provides a software test scope determination device based on a bipartite graph, the device comprising:

[0029] A code difference acquisition module is used to obtain the changed files and corresponding changed line numbers between the first version of the code and the second version of the code;

[0030] a modified function determining module, configured to determine, based on the modified file, the modified function to which the modified line number belongs;

[0031] A function impact determination module is used to determine the function points corresponding to the modified function by calling the link, and determine the affected frequency of each function point; the affected frequency is the sum of the number of times different modified functions affect the same function point;

[0032] A bipartite graph modeling module, configured to construct a bipartite graph model with the modification function as a first vertex set and the function point as a second vertex set; each edge in the edge set of the bipartite graph model represents an impact association established between the modification function and the function point via a call link;

[0033] A minimum cover solving module is used to solve the bipartite graph model using a bipartite graph minimum vertex cover algorithm, and generate a minimum set of function points covering all associated edges from the function points, so that at least one function point affected by each modification function is selected;

[0034] The test set generation module is used to sort the minimum function point set according to the affected frequency of the function points and generate a target test set with test priority.

[0035] In a third aspect, the present application provides a software test scope determination device based on a bipartite graph, the device comprising: a processor and a memory;

[0036] The memory is used to store program code and transmit the program code to the processor;

[0037] The processor is configured to execute the steps of the method for determining the software test scope based on a bipartite graph introduced in any implementation of the first aspect according to the instructions in the program code.

[0038] A fourth aspect of the present application provides a computer-readable storage medium for storing program code, wherein the program code is used to execute the steps of the software test scope determination method based on a bipartite graph introduced in any implementation of the first aspect.

[0039] Compared with the existing technology, this application has the following beneficial effects:

[0040] In the technical solution of the present application, firstly, the changed files and corresponding changed line numbers between the first version code and the second version code are obtained; then, the changed function to which the changed line number belongs is determined based on the changed file; then, the function point corresponding to the changed function is determined through the call link, and the affected frequency of each function point is determined; the affected frequency is the sum of the number of times different changed functions affect the same function point; then, a bipartite graph model is constructed with the changed function as the first vertex set and the function point as the second vertex set; each edge in the edge set of the bipartite graph model represents the impact association established between the changed function and the function point through the call link; then, the bipartite graph minimum vertex cover algorithm is used to solve the bipartite graph model, and a minimum function point set covering all associated edges is generated from the function point, so that at least one function point affected by each changed function is selected; finally, the minimum function point set is sorted according to the affected frequency of the function point, and a target test set with test priority is generated. It can be seen that in the technical solution of the present application, an automated and quantitative test range optimization method is constructed by combining code change analysis with graph theory algorithms. By accurately identifying code changes and locating modified functions, the subjectivity of manual judgment is eliminated. Call chain analysis establishes a mapping relationship between modified functions and functional points, quantifying the frequency of impact. A bipartite graph minimum vertex cover algorithm is used to calculate the minimum set of functional points required for testing, avoiding the waste of resources required for full testing. Tests are prioritized based on the frequency of impact, ensuring that high-risk functions are verified first. This solution efficiently and accurately determines the minimum test scope, significantly improving test efficiency while ensuring test adequacy. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0042] Figure 1 A flowchart of a method for determining software test scope based on a bipartite graph provided in an embodiment of the present application;

[0043] Figure 2 A schematic diagram of a bipartite graph model provided in an embodiment of the present application;

[0044] Figure 3 A flowchart of another method for determining software test scope based on a bipartite graph provided in an embodiment of the present application;

[0045] Figure 4 A schematic structural diagram of a software test scope determination device based on a bipartite graph provided in an embodiment of the present application. DETAILED DESCRIPTION

[0046] As described above, the current software testing scope suffers from inaccurate determination and low efficiency.

[0047] After research, the inventors proposed a software test scope determination method based on a bipartite graph and related products.

[0048] First, obtain the changed files and corresponding changed line numbers between the first version code and the second version code; then determine the changed function to which the changed line number belongs based on the changed file; then determine the function point corresponding to the changed function through the call link, and determine the affected frequency of each function point; the affected frequency is the sum of the number of times different changed functions affect the same function point; then construct a bipartite graph model with the changed function as the first vertex set and the function point as the second vertex set; each edge in the edge set of the bipartite graph model represents the impact association established between the changed function and the function point through the call link; then use the bipartite graph minimum vertex cover algorithm to solve the bipartite graph model, and generate the minimum function point set covering all associated edges from the function point, so that at least one function point affected by each changed function is selected; finally, sort the minimum function point set according to the affected frequency of the function point, and generate a target test set with test priority. It can be seen that in the technical solution of this application, an automated and quantitative test range optimization method is constructed by combining code change analysis with graph theory algorithms. By accurately identifying code changes and locating modified functions, the subjectivity of manual judgment is eliminated. Call chain analysis establishes a mapping relationship between modified functions and functional points, quantifying the frequency of impact. A bipartite graph minimum vertex cover algorithm is used to calculate the minimum set of functional points required for testing, avoiding the waste of resources required for full testing. Tests are prioritized based on frequency of impact, ensuring that high-risk functions are verified first. This solution significantly improves testing efficiency while ensuring test adequacy.

[0049] In order to help those skilled in the art better understand the present invention, the following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.

[0050] See also Figure 1 , which is a flow chart of a method for determining software test scope based on a bipartite graph provided in an embodiment of the present application. Figure 1 As shown, the method includes the following steps:

[0051] S101: Obtain the changed files and corresponding changed line numbers between the first version code and the second version code.

[0052] In the embodiment of the present application, the first version code refers to the baseline version code before modification, such as the released stable version or the code version of the previous iteration cycle. The second version code refers to the modified version code to be tested containing code changes.

[0053] Changed files refer to files whose content has been added, modified, or deleted between two versions of the code. These files include source code files and configuration files. The line numbers of the code lines where the content has changed in the changed files are called changed line numbers. For example, starting from the first line of the file, the changed line numbers are line 11 (the new log line) and line 13 (the modified return statement).

[0054] In an embodiment of the present application, a first version code and a second version code may be compared using a version control tool (such as Git) to obtain the changed file paths and corresponding changed line numbers between the two versions of the code.

[0055] For example, the stable version of a software is V1.0 (the first version of the code). The development team completes an optimization of a module and submits it to V1.1 (the second version of the code). The changed files between V1.0 and V1.1 obtained through Git are File A, File B, and File C. The changed line number of File A is line 15, the changed line number of File B is line 30, and the changed line number of File C is line 5.

[0056] In the embodiment of the present application, the changed line number is the basis for locating the modified function in subsequent steps.

[0057] S102: Determine the modified function to which the changed line number belongs based on the changed file.

[0058] In an embodiment of the present application, the modified function is a function or method in a change file that is affected by code changes (such as addition, modification or deletion), specifically, a change in the code line in the function body, or a change in the method declaration (such as parameters, return value).

[0059] In one exemplary implementation, a code parsing tool can be used to analyze the modified file obtained in the aforementioned step to determine the modified function to which the modified line number belongs. For example, if the code parsing tool determines that the modified line 15 in file A is located within function A, then the modified function indicated by the modified line number is function A.

[0060] S103: Determine the function points corresponding to the modified function through the call link, and determine the affected frequency of each function point.

[0061] In the embodiment of the present application, the call link refers to the call relationship chain between functions, which is used to track the impact of modified functions on upper-level functions.

[0062] A function point refers to an independently verifiable business function in a software system, such as "user query" and "order creation", which is associated with the function in the code through interface routing (such as URL path).

[0063] In the embodiment of the present application, the affected frequency is the sum of the number of times different modified functions affect the same function point, that is, how many modified functions are associated with the function point through the call link.

[0064] In this embodiment of the present application, the function points corresponding to the modified functions determined in the above steps can be tracked through the call link. If N modification functions all affect a certain function point, the frequency of influence of the function point is recorded as N (i.e., it is affected by N modification functions), where N is a positive integer.

[0065] In an optional implementation, in order to facilitate the subsequent generation of a bipartite graph model, after determining the functional points corresponding to the modified function through the call link and determining the affected frequency of each functional point, a bipartite graph model table can be created based on the modified function and its corresponding functional point determined in the previous steps, as well as the affected frequency of each functional point.

[0066] Table 1 is a bipartite graph model table provided in an embodiment of the present application. As shown in Table 1, the change functions to which the changed line numbers between the two versions of the code belong are F1, F2, F3, F4, and F5. Among them, the function points corresponding to the change function F1 are A and B, the function points corresponding to the change function F2 are A, C, and D, the function point corresponding to the change function F3 is C, the function point corresponding to the change function F4 is C, and the function points corresponding to the change function F5 are B and E. The affected frequency of function point A is 2, the affected frequency of function point B is 2, the affected frequency of function point C is 3, the affected frequency of function point D is 1, and the affected frequency of function point E is 1.

[0067] Table 1 Bipartite graph model table

[0068] Function Points Modify the function Frequency of impact A F1, F2 2 B F1, F5 2 C F2, F3, F4 3 D F2 1 E F5 1

[0069] S104: Construct a bipartite graph model with the change function as the first vertex set and the function point as the second vertex set.

[0070] The bipartite graph model is a graph structure in graph theory. The vertices are in two disjoint sets (U set and V set). All edges in the bipartite graph model exist only between the two sets, and there are no edges within the same set.

[0071] In this embodiment of the present application, a bipartite graph model is constructed using the modification functions determined in the previous step as the first vertex set, i.e., the U set; and the function points determined in the previous step as the second vertex set, i.e., the V set. Each edge in the edge set of the constructed bipartite graph model represents the impact relationship established between the modification function and the function point through a call link, that is, a modification function affects a function point through a call link.

[0072] Figure 2 A schematic diagram of a bipartite graph model provided in an embodiment of the present application. Figure 2 The bipartite graph model shown is constructed based on the data in Table 1 as an example.

[0073] In the embodiment of the present application, the relationship between complex modification functions and functional points is converted into a standard graph structure, and a graph theory algorithm is used to find the optimal solution.

[0074] S105. Solve the bipartite graph model using a bipartite graph minimum vertex cover algorithm, and generate a minimum set of function points covering all associated edges from the function points, so that at least one function point affected by each modification function is selected.

[0075] In the present embodiment, minimum vertex cover for a bipartite graph refers to selecting a minimum number of function points (a subset of the second vertex set) in a bipartite graph model with modification functions as a first vertex set and function points as a second vertex set, such that at least one edge associated with each modification function (each element in the first vertex set) is covered by the selected function points. In other words, at least one function point corresponding to each modification function is included in the test scope, thereby ensuring that the impact of all modification functions is verified.

[0076] In the embodiments of the present application, a bipartite graph minimum vertex cover algorithm is an algorithm for solving a bipartite graph minimum vertex cover, such as an algorithm based on maximum matching, a greedy algorithm, an integer linear programming, or a branch and bound method. In practical applications, different bipartite graph minimum vertex cover algorithms can be selected according to actual needs, and the specific bipartite graph minimum vertex cover algorithm is not limited here.

[0077] In one example implementation, a bipartite graph minimum vertex cover algorithm is used to solve Figure 2 The bipartite graph model shown in , then the minimum function point set is S = {B, C}. Figure 2 As shown, the edge (F1, B) of F1 is covered by B, the edge (F2, C) of F2 is covered by C, the edge (F3, C) of F3 is covered by C, the edge (F4, C) of F4 is covered by C, and the edge (F5, B) of F5 is covered by B. It can be seen that the impact paths of all modified functions are covered, and the set S = {B, C} is the minimum cover.

[0078] In an optional implementation, the bipartite graph minimum vertex cover algorithm is the Hopcroft-Karp algorithm. The specific steps for solving the minimum vertex cover of a bipartite graph model using the Hopcroft-Karp algorithm are as follows:

[0079] Step 1: Initialize the maximum matching M to an empty set;

[0080] Step 2: Use Breadth First Search (BFS) to find the shortest augmenting path.

[0081] Step 3:

[0082]

[0083] Step 4: According to Theorem, generate a minimum vertex cover S from a maximum matching M:

[0084] First, mark all unmatched first vertex sets as "uncovered", then mark the reachable vertices by alternating paths, and finally

[0085] S = all unmarked vertices of the first vertex set + all marked vertices of the second fixed point set.

[0086] 5. Return the minimum vertex cover S.

[0087] S106 , sorting the minimum function point set according to the affected frequencies of the function points, and generating a target test set with test priority.

[0088] In an optional implementation, the minimum function point set is sorted from high to low according to the frequency of impact, and the function point with a higher frequency of impact has a higher test priority, thereby generating a minimum test set with priority.

[0089] In the embodiment of the present application, the minimum function point set obtained in the above steps is S={B, C}. According to Table 1, the affected frequency of B is 2, and the affected frequency of C is 3.

[0090] Sort in descending order of affected frequency: C (affected frequency 3), B (affected frequency 2).

[0091] Generate a minimum test set with priority. Table 2 is a schematic table of a minimum test set with priority provided in an embodiment of the present application.

[0092] Table 2

[0093] Function Points Frequency of impact Modify the function C 3 F2, F3, F4 B 2 F1, F5

[0094] In the embodiment of the present application, if the affected frequencies are the same, they can be sorted according to the importance of the functional points in actual applications or other regular orders, and the specific sorting method is not limited here.

[0095] The embodiment of the present application combines code change analysis with graph theory algorithms to construct an automated and quantitative test scope optimization method. By accurately identifying code changes and locating modified functions, the subjectivity of manual judgment is eliminated; by establishing a mapping relationship between modified functions and functional points through call link analysis, the affected frequency is quantified, solving the problem of indirect impacts being difficult to track in complex systems; using the bipartite graph minimum vertex cover algorithm to calculate the minimum set of functional points that must be tested, avoiding the waste of resources for full testing; and sorting test priorities according to the affected frequency, ensuring that high-risk functions are verified first. This solution significantly improves test efficiency while ensuring test adequacy.

[0096] Figure 3 This is a flowchart of another method for determining software test scope based on a bipartite graph provided in an embodiment of the present application. In the embodiment introduced by this figure, a more detailed description is provided for the implementation of the flowchart of the method for determining software test scope based on a bipartite graph.

[0097] S301: Obtain change information between a first version code and a second version code through a difference comparison command.

[0098] In an embodiment of the present application, the difference comparison command is a tool or instruction for comparing the differences between two code versions, and can output newly added, modified or deleted code snippets.

[0099] The difference comparison command can be selected based on the version control tool used. For example, with Git, you can use the Git Diff command to obtain change information; with Subversion, you can use the SVN Diff command to obtain change information. The specific version control tool and difference comparison command are not limited here.

[0100] S302: Extract the changed files and their corresponding changed line numbers based on the change information.

[0101] In the embodiment of the present application, the change information obtained in the previous step is parsed, the changed file paths are extracted from the change information, and then for each changed file, the line number where the content is changed is further extracted.

[0102] S303: Convert the changed file into an abstract syntax tree using a syntax parsing tool.

[0103] In an embodiment of the present application, the syntax parsing tool is a library or framework that converts source code into a structured tree representation.

[0104] Abstract Syntax Tree (AST) refers to the tree structure representation of source code, where each node corresponds to a code element (such as a class, method, or expression).

[0105] Use different syntax parsing tools for different languages to parse the modified files extracted in the previous step. For example, for Java, use the JavaParser library to parse .java files; for Python, use the ast module in the standard library to parse .py files; and for JavaScript, use the Babel or Esprima parser to generate an abstract syntax tree.

[0106] In the embodiment of the present application, through this conversion, the code can be represented in a structured manner, which facilitates subsequent analysis and operation of the code.

[0107] S304: traverse the abstract syntax tree to locate the modified function to which the changed line number belongs.

[0108] In the embodiments of this application, Java is used as an example. In the Java programming language system, the concept of "function" is usually called "method". It is a reusable block of code defined in a class or object to perform a specific task.

[0109] In one example implementation, after obtaining the AST generated by parsing the modified file using the JavaParser library, the abstract syntax tree is traversed. During the traversal, the starting and ending line numbers of each method node (i.e., function node) are found and compared with the previously extracted modified line numbers. For example, if the modified line 11 of file A is found to be within the code block of method A during the traversal, method A is determined to be the modified function.

[0110] S305: Determine whether the modified function is an interface layer function.

[0111] In the embodiment of the present application, the interface layer function refers to the entry function that directly processes external requests, and usually includes routing annotations.

[0112] In the embodiment of this application, for the Spring framework, you can determine whether the modified function corresponding to the method node is an interface layer function by checking whether the method node contains annotations such as @RequestMapping and @GetMapping; for the Python Flask framework, you can determine whether the function is an interface layer function by checking whether it is decorated with the @app.route decorator. The specific determination method can be selected according to the actual application framework and is not limited here.

[0113] In the embodiment of the present application, if the modified function is an interface layer function, proceed to step S306; if the modified function is a non-interface layer function, proceed to step S307.

[0114] S306. Obtain the function route of the modified function through the abstract syntax tree, extract the class route from the route annotation in the abstract syntax tree, concatenate the class route and the function route to form complete routing information, and determine the corresponding function point based on the complete routing information and the preset mapping relationship between routing and function points.

[0115] In an embodiment of the present application, if the modified function is an interface layer function, the function route is obtained through the abstract syntax tree where it is located.

[0116] In one example implementation, the @GetMapping(" / users / {id}") annotation can be parsed to obtain the function route as / users / {id}. Next, the routing annotation is searched for within the class's abstract syntax tree node. Assuming class A has the @RequestMapping(" / api / users") annotation, the class route is extracted as / api / users. The class route and the function route are concatenated to obtain the complete route: / api / users / users / {id}.

[0117] During the development process, a mapping table between routes and function points is maintained in advance. By querying this table, the function point corresponding to / api / users / users / {id} can be determined.

[0118] S307. Recursively trace the upper-level function that calls the modified function in the call link until the interface-level function is located; obtain the function route of the interface-level function through the abstract syntax tree, and extract the class route from the route annotation in the abstract syntax tree, splice the class route and the function route to form complete routing information, and determine the corresponding function point based on the preset routing and function point mapping relationship according to the complete routing information.

[0119] In an embodiment of the present application, if the modified function is a non-interface layer function, starting from the modified function, recursively trace the upper-layer function that calls it in the call link. First, find other methods that call the modified function. Suppose that function C is called in function A of class B. Then check whether function C is an interface layer function. If the class where function C is located is modified by the @RestController annotation and the function is modified by the @PostMapping(" / users") annotation, it belongs to the interface layer function. According to the method of step S306, the function route / users is obtained from its abstract syntax tree, and the class route is assumed to be / api, and the complete route / api / users is spliced together. According to the preset routing and function point mapping relationship, the corresponding function point is determined.

[0120] S308: Determine the impact frequency of each functional point.

[0121] S309: Construct a bipartite graph model with the change function as the first vertex set and the function point as the second vertex set.

[0122] S310. Solve the bipartite graph model using a bipartite graph minimum vertex cover algorithm, and generate a minimum set of function points covering all associated edges from the function points, so that at least one function point affected by each modification function is selected.

[0123] S311. Sort the minimum function point set according to the affected frequency of the function points to form a target test set with test priority.

[0124] S308-S311 are implemented in a manner substantially the same as S103-S106 in the method embodiment described above, and are not described in detail here. For related technical implementations, reference may be made to the above description of S103-S106.

[0125] In the embodiment of the present application, the change information between code versions is accurately obtained through the difference comparison command, refined to the file path and line number, and then the changed file is converted into an abstract syntax tree with the help of a syntax parsing tool. The modified function is located and judged by whether it is an interface layer function. The corresponding functional point is determined by extracting the route or recursively tracing the call link. Then the frequency of the affected functional point is determined, a bipartite graph model is constructed and the minimum vertex cover algorithm is used to generate the minimum functional point set. Finally, the target test set is formed by sorting according to the frequency. It avoids the subjectivity of manual experience judgment and the redundancy of full-scale testing. By accurately locating the affected functional points, optimizing the test scope, and quantifying the test priority, it effectively improves the accuracy and efficiency of testing. At the same time, it is compatible with a variety of version control tools, programming languages and technical frameworks, has wide applicability and scalability, and provides an efficient test scope determination method for iterative testing of complex software systems.

[0126] Based on the software test scope determination method based on a bipartite graph provided in the aforementioned embodiment, the present application also provides a software test scope determination device based on a bipartite graph. Figure 4 This is a schematic diagram of the structure of a software test range determination device based on a bipartite graph provided in an embodiment of the present application. Figure 4 As shown, the software test scope determination device based on bipartite graph includes: a code difference acquisition module 401, a modified function determination module 402, a functional impact determination module 403, a bipartite graph modeling module 404, a minimum coverage solution module 405 and a test set generation module 406.

[0127] The code difference obtaining module 401 is used to obtain the changed files and corresponding changed line numbers between the first version code and the second version code.

[0128] The modified function determination module 402 is configured to determine the modified function to which the modified line number belongs based on the modified file.

[0129] The function impact determination module 403 is used to determine the function points corresponding to the modified function through the call link, and determine the affected frequency of each function point; the affected frequency is the sum of the number of times different modified functions affect the same function point.

[0130] The bipartite graph modeling module 404 is used to construct a bipartite graph model with the modification function as the first vertex set and the function point as the second vertex set; each edge in the edge set of the bipartite graph model represents the influence association established between the modification function and the function point through the call link.

[0131] The minimum cover solving module 405 is used to solve the bipartite graph model using the bipartite graph minimum vertex cover algorithm, and generate a minimum set of function points covering all associated edges from the function points, so that at least one function point affected by each change function is selected.

[0132] In an optional implementation, the bipartite graph minimum vertex cover algorithm used in the minimum cover solving module 405 is the Hopcroft-Karp algorithm.

[0133] The test set generating module 406 is configured to sort the minimum function point set according to the affected frequencies of the function points, and generate a target test set with test priorities.

[0134] The embodiment of the present application combines the functions of the code difference acquisition module 401, the modified function determination module 402, the functional impact determination module 403, the bipartite graph modeling module 404, the minimum coverage solution module 405 and the test set generation module 406, thereby significantly improving the testing efficiency while ensuring that the software testing scope is fully determined.

[0135] Optionally, the code difference acquisition module 401 is specifically configured to:

[0136] Obtain the change information between the first version code and the second version code through the difference comparison command;

[0137] Based on the change information, the changed files and their corresponding changed line numbers are extracted.

[0138] Optionally, the modified function determination module 402 is specifically configured to:

[0139] Converting the changed file into an abstract syntax tree using a syntax parsing tool;

[0140] The abstract syntax tree is traversed to locate the modified function to which the changed line number belongs.

[0141] Optionally, the modified function determination module 402 is further configured to determine whether the modified function is an interface layer function.

[0142] Optionally, the function impact determination module 403 is specifically configured to:

[0143] If the modified function is an interface layer function, obtaining a function route of the modified function through the abstract syntax tree, extracting a class route from the route annotation in the abstract syntax tree, concatenating the class route and the function route to form complete routing information, and determining a corresponding function point based on the complete routing information and a preset mapping relationship between routing and function points;

[0144] If the modified function is a non-interface layer function, recursively trace the upper-layer function that calls the modified function in the call link until the interface layer function is located; obtain the function route of the interface layer function through the abstract syntax tree, and extract the class route from the routing annotation in the abstract syntax tree, splice the class route and the function route to form complete routing information, and determine the corresponding function point based on the preset routing and function point mapping relationship according to the complete routing information.

[0145] Optionally, the test set generation module 406 is specifically configured to sort the minimum function point set according to the affected frequency from high to low, wherein the function point with a higher affected frequency has a higher test priority, and a minimum test set with priority is generated.

[0146] In addition, an embodiment of the present application further provides a software test scope determination device based on a bipartite graph, wherein the software test scope determination device based on a bipartite graph includes a processor and a memory.

[0147] The memory is used to store program code and transmit the program code to the processor;

[0148] The processor is configured to execute the steps of the software test range determination method based on a bipartite graph as described in any one of the above method embodiments according to the instructions in the program code.

[0149] In addition, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the program is executed by a processor, the software test scope determination method based on a bipartite graph as described in any method embodiment is implemented.

[0150] It should be noted that the various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device and equipment embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The device and equipment embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components indicated as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. A person of ordinary skill in the art can understand and implement it without expending creative work.

[0151] The above is merely one specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A software test scope determination method based on bipartite graph, characterized in that: The method comprises: Get the changed files and corresponding changed line numbers between the first version code and the second version code; Determine the modified function to which the modified line number belongs based on the modified file; Determine the function point corresponding to the modified function by calling the link, and determine the affected frequency of each function point; the affected frequency is the sum of the number of times different modified functions affect the same function point; A bipartite graph model is constructed with the modification function as a first vertex set and the function point as a second vertex set; each edge in the edge set of the bipartite graph model represents an impact association established between the modification function and the function point through a call link; Solving the bipartite graph model using a bipartite graph minimum vertex cover algorithm, generating a minimum set of function points covering all associated edges from the function points, so that at least one function point affected by each modification function is selected; The minimum function point set is sorted according to the affected frequencies of the function points to generate a target test set with test priorities.

2. The method according to claim 1, characterized in that The step of obtaining the changed files and corresponding changed line numbers between the first version of the code and the second version of the code includes: Obtain the change information between the first version code and the second version code through the difference comparison command; Based on the change information, the changed files and their corresponding changed line numbers are extracted.

3. The method according to claim 1, characterized in that The determining, based on the changed file, the changed function to which the changed line number belongs, includes: Converting the changed file into an abstract syntax tree using a syntax parsing tool; The abstract syntax tree is traversed to locate the modified function to which the changed line number belongs.

4. The method according to claim 3, characterized in that After traversing the abstract syntax tree to locate the modified function to which the changed line number belongs, the method further includes: Determine whether the modified function is an interface layer function.

5. The method according to claim 4, characterized in that Determining the functional point corresponding to the modified function by calling the link includes: If the modified function is an interface layer function, obtaining a function route of the modified function through the abstract syntax tree, extracting a class route from the route annotation in the abstract syntax tree, concatenating the class route and the function route to form complete routing information, and determining a corresponding function point based on the complete routing information and a preset mapping relationship between routing and function points; If the modified function is a non-interface layer function, recursively trace the upper-layer function that calls the modified function in the call link until the interface layer function is located; obtain the function route of the interface layer function through the abstract syntax tree, and extract the class route from the routing annotation in the abstract syntax tree, splice the class route and the function route to form complete routing information, and determine the corresponding function point based on the preset routing and function point mapping relationship according to the complete routing information.

6. The method according to claim 1, characterized in that The bipartite graph minimum vertex cover algorithm is the Hopcroft-Karp algorithm.

7. The method according to claim 1, characterized in that The step of sorting the minimum function point set according to the affected frequencies of the function points to generate a target test set with test priorities includes: The minimum function point set is sorted from high to low according to the affected frequency, a function point with a higher affected frequency has a higher test priority, and a minimum test set with priority is generated.

8. A software test scope determination device based on bipartite graph, characterized in that: The device comprises: A code difference acquisition module is used to obtain the changed files and corresponding changed line numbers between the first version of the code and the second version of the code; a modified function determining module, configured to determine, based on the modified file, the modified function to which the modified line number belongs; A function impact determination module is used to determine the function points corresponding to the modified function by calling the link, and determine the affected frequency of each function point; the affected frequency is the sum of the number of times different modified functions affect the same function point; A bipartite graph modeling module, configured to construct a bipartite graph model with the modification function as a first vertex set and the function point as a second vertex set; each edge in the edge set of the bipartite graph model represents an impact association established between the modification function and the function point via a call link; A minimum cover solving module is used to solve the bipartite graph model using a bipartite graph minimum vertex cover algorithm, and generate a minimum set of function points covering all associated edges from the function points, so that at least one function point affected by each modification function is selected; The test set generation module is used to sort the minimum function point set according to the affected frequency of the function points and generate a target test set with test priority.

9. A software test scope determination device based on a bipartite graph, characterized in that: include: Processor and memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the steps of the software test scope determination method based on a bipartite graph according to any one of claims 1 to 7 according to the instructions in the program code.

10. A computer-readable storage medium, characterized in that The computer-readable storage medium is used to store program codes, and the program codes are used to execute the steps of the software test scope determination method based on a bipartite graph according to any one of claims 1 to 7.