Code change influence identification and automatic test execution method and system
By constructing a semantic graph and combining it with multi-strategy analysis, the entry nodes for code changes are identified, the probability of these nodes being affected is calculated, and test cases are automatically generated. This solves the problems of inaccurate and inefficient testing in existing technologies, and achieves efficient and accurate identification of the impact of code changes and automated testing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 武汉易久数科智能机器人有限公司
- Filing Date
- 2026-01-23
- Publication Date
- 2026-04-17
AI Technical Summary
Existing technologies suffer from incomplete test coverage, inaccurate impact analysis, and low testing efficiency in identifying and executing code change impacts, especially under complex architectures, making it difficult to meet the requirements of modern software development for test accuracy, comprehensiveness, and efficiency.
By acquiring code data, dependency relationships, and call chain data, a semantic graph is constructed. Combining static analysis, dynamic analysis, and semantic understanding strategies, change entry nodes are identified, and the probability of nodes being affected is calculated using a probabilistic graphical model. Targeted test cases are then automatically generated for automated testing.
It enables comprehensive impact analysis of code changes, improves test coverage and efficiency, achieves an accuracy of over 92%, increases coverage from 65% to over 95%, reduces test time by 60%, reduces defect miss rate to below 3%, and adapts to complex architecture scenarios.
Smart Images

Figure CN121880205A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software development technology, specifically to a method and system for identifying the impact of code changes and for automated test execution. Background Technology
[0002] In the modern software development field, code changes are becoming increasingly frequent. Accurately identifying the scope of impact caused by these changes and executing targeted tests to ensure software quality has become a core technical challenge for the industry. Traditional testing methods are ill-suited to the quality assurance needs of complex architectures, necessitating more efficient and precise technical solutions.
[0003] Currently, the relevant technologies in the field of software testing and quality assurance mainly fall into three categories: First, static code analysis tools, which identify syntactic dependencies by parsing the code syntax structure, but cannot capture dynamic interactions at runtime; second, dynamic analysis tools, which help determine the scope of impact by collecting call path data in the actual operating environment, but have limitations such as limited coverage scenarios and reliance on production environment data; and third, traditional testing methods, which rely on the experience of developers to determine the scope of testing, are highly subjective and inefficient, and are difficult to adapt to large-scale complex systems.
[0004] In the prior art, the closest implementation to this invention is a test impact analysis method based on call chain analysis, and its specific implementation steps are as follows: First, service call relationship data is collected from call chain tracing systems such as Jaeger and Zipkin; second, a service dependency graph is constructed based on the collected call chain data; third, when the code changes, the service that may be affected is traversed in the dependency graph; finally, test case execution suggestions are provided to developers based on the impact analysis results.
[0005] However, the aforementioned existing technical solutions have significant drawbacks: First, relying solely on dynamic call chain data fails to capture static dependencies between code segments, resulting in incomplete impact analysis dimensions. Second, lacking code semantic understanding capabilities, they cannot identify the business intent behind changes and accurately determine indirect impact paths. Third, impact assessment employs a simple graph traversal approach without incorporating probabilistic models, leading to insufficient accuracy in the analysis results. Fourth, test case selection and generation depend on manual experience, failing to automatically generate targeted test cases, resulting in omissions in test coverage and requiring the execution of numerous redundant test cases, wasting computational resources and extending the testing cycle. Furthermore, in existing technologies, production call chains, code semantics, and business process information are scattered across different systems, lacking a unified data model to support accurate impact reasoning, further exacerbating the problems of inaccurate impact analysis and low testing efficiency.
[0006] In summary, existing technologies have significant shortcomings in identifying the impact of code changes on complex architectures and in executing tests, making it difficult to meet the requirements of modern software development for testing accuracy, comprehensiveness, and efficiency. Summary of the Invention
[0007] In view of this, the purpose of this invention is to provide a method and system for identifying the impact of code changes and for automated test execution, so as to solve the problems of incomplete test coverage, inaccurate impact analysis and low test efficiency in the prior art.
[0008] According to a first aspect of the present invention, a method for identifying the impact of code changes and executing automated tests is provided, comprising: Retrieve code data, code dependencies, and call chain data; Extract class nodes, method nodes, interface nodes, and data structure nodes from the code data. Based on the code dependencies, construct relationship edges between the nodes and set the weights of the relationship edges to obtain a semantic graph. When code changes are detected, static analysis strategies are used to analyze the syntax structure and type information of the code changes, dynamic analysis strategies are used to identify the actual call paths based on historical call chain data, and semantic understanding strategies are used to analyze the semantic intent of the code changes using a large language model. Based on the analysis results of the three strategies, the change entry nodes are identified, and a set of entry nodes is constructed. Based on the set of entry nodes, semantic graph, and preset propagation threshold, the probability of each node being affected is calculated to obtain the impact analysis results; Obtain the test cases associated with each affected node, execute the tests according to the test cases, and obtain the test results.
[0009] Preferably, based on the set of entry nodes, the semantic graph, and a preset propagation threshold, the probability of each node being affected is calculated, including: S61. Set the initial probability of the entry node being affected to 1, and set the initial probability of other nodes being affected to 0; integrate all entry nodes into a processing node queue. S62. Take a node from the processing node queue and designate it as node u; S63. For each neighbor node v of node u, calculate the propagation probability of node u to node v based on the weight of the relation edge, the probability of node u being affected, and the decay factor. S64. If the propagation probability of node u to node v is greater than the influence probability of node v, then the propagation probability of node u to node v is assigned to the influence probability of node v. S65. If the probability of node v being affected is greater than the preset propagation threshold, then node v is placed into the processing node queue. S66. If the processing node queue is not empty, repeat steps S62 to S65; otherwise, execute S67. S67. Output all nodes whose probability of being affected is greater than the preset propagation threshold, and the probability of being affected corresponding to each node.
[0010] Preferably, the method further includes: The extracted class nodes, method nodes, interface nodes, and data structure nodes are labeled with attributes, including node ID, node type, code location, and business tags. The business tags are business semantics extracted from code comments and business documents.
[0011] Preferably, based on code dependencies, relationship edges are constructed between the nodes, including: If a call relationship exists between two nodes, then construct a call relationship edge between the two nodes; If an inheritance relationship exists between two nodes, then an inheritance relationship edge is constructed between the two nodes; If an implementation relationship exists between two nodes, then an implementation relationship edge is constructed between the two nodes; If there is a usage relationship between two nodes, then construct a usage relationship edge between the two nodes; If a data flow relationship exists between two nodes, then construct a data flow relationship edge between the two nodes.
[0012] Preferably, the weights of the relation edges are set, including: From historical test data of the code data, obtain the test pass rate of the code path of each relationship edge; obtain the call frequency of the code path of each relationship edge in the production environment; read the importance weight of each relationship edge from business documents and user configurations as the business importance; obtain the historical change frequency of the code path of each relationship edge; The weight of a relation edge is calculated based on its test pass rate, call frequency, business importance, and historical change frequency.
[0013] Preferably, obtain test cases related to each affected node, including: Retrieve test cases related to the affected nodes from the existing test case library, and / or generate test cases using a large language model based on the code, business description, and test requirements of the affected nodes.
[0014] Preferably, the method further includes: Analyze the test results and update the weights of relation edges in the semantic graph based on the analysis results.
[0015] According to a second aspect of the present invention, a system for identifying the impact of code changes and automating test execution is provided, comprising at least: The application service layer includes: a data acquisition module, used to acquire code data, code dependency relationships, and call chain data; The graph construction module is used to extract class nodes, method nodes, interface nodes, and data structure nodes from code data. Based on code dependencies, it constructs relationship edges between nodes and sets the weights of these relationship edges to obtain a semantic graph. The reasoning and analysis module is used to analyze the syntax structure and type information of the code change using static analysis strategy, identify the actual call path based on historical call chain data using dynamic analysis strategy, and analyze the semantic intent of the code change using a large language model using semantic understanding strategy when code changes are detected. Based on the analysis results of the three strategies, the change entry node is identified and a set of entry nodes is constructed. Based on the set of entry nodes, semantic graph and preset propagation threshold, the probability of each node being affected is calculated to obtain the impact analysis results. The test management module is used to manage the lifecycle of test cases; The execution orchestration module is used to obtain test cases related to each affected node, execute tests based on the test cases, and obtain test results.
[0016] Preferably, the system further includes: The data processing layer includes a data cleaning module, a feature extraction module, and a model training module; The data cleaning module is used to remove duplicate values, process missing values and outliers from the acquired raw data. The feature extraction module is used to extract valid data from the acquired raw data; The model training module is used to train the models required by the application service layer based on historical data.
[0017] Preferably, the system further includes: The front-end layer is used to provide the user interface. The storage layer is used to store data generated during the execution of the application service layer. The message layer is used to transmit event streams and provide asynchronous communication channels for internal system components; The monitoring layer is used to collect system performance metrics and manage logs.
[0018] The technical solution provided by this invention may include the following beneficial effects: It is understood that the technical solution presented in this invention extracts various types of nodes from code data, constructs relationship edges between nodes based on code dependencies, and sets weights to obtain a semantic graph. When the code changes, static analysis, dynamic analysis, and semantic understanding strategies are used to analyze and identify the entry point node for the change. Based on each entry point node, the semantic graph, and a preset propagation threshold, the probability of each node being affected is calculated. Test cases related to each affected node are obtained and executed to obtain test results. It is understood that this technical solution combines static analysis, dynamic analysis, and semantic understanding to comprehensively capture the direct and indirect impacts of code changes, thereby enabling test cases to fully cover affected nodes and achieving high testing efficiency.
[0019] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit the invention. Attached Figure Description
[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.
[0021] Figure 1 This is a schematic diagram illustrating the steps of a method for identifying the impact of code changes and executing automated tests according to an exemplary embodiment; Figure 2 This is an architecture diagram illustrating a method for identifying the impact of code changes and executing automated tests, according to an exemplary embodiment. Figure 3 This is a flowchart illustrating a method for identifying the impact of code changes and executing automated tests according to an exemplary embodiment; Figure 4 This is a data flow diagram illustrating a method for identifying the impact of code changes and executing automated tests, according to an exemplary embodiment. Detailed Implementation
[0022] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numerals in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present invention. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the invention as detailed in the appended claims.
[0023] In one embodiment, see Figure 1 , Figure 2 , Figure 3 and Figure 4 This provides a method for identifying the impact of code changes and executing automated tests, including: Step S11: Obtain code data, code dependencies, and call chain data.
[0024] This step involves data collection to provide a data foundation for subsequent steps. Its core objective is to comprehensively gather multi-dimensional key data covering the entire code lifecycle, providing complete and high-quality data support for subsequent structured graph construction, dependency resolution, and semantic association mining. Preferably, comprehensive data collection can be conducted from four key data sources: From Git repositories, deeply extract code change history (including modified files, code snippets, commit logs, and version iteration paths for each commit), the project's file hierarchy, and static dependencies at the code level (such as calls, inheritance, and implementation relationships between classes, methods, functions, and modules). This data is the core basis for analyzing the static structure and change trajectory of the code; Through CI / CD systems (such as Jenkins, GitLab CI, and other mainstream tools), collect detailed log information during the build process, execution results of tests at each stage (including pass status, failure reasons, and defect details), and code deployment records (such as deployment environment, deployment time, and version identifiers) to help accurately grasp the actual implementation of the code in the engineering process; Relying on call chain tracing systems (such as Jaeger, Zipkin, and SkyWalking)... (etc.) Capture the service call relationship chain, response time, throughput and other performance data of each call link in the actual operation of the production environment, and completely restore the dynamic interaction scenario of the system during operation; at the same time, comprehensively obtain the specific content, execution logic, expected results and code coverage of each type of existing test case from the test case library, as well as the covered classes, methods or interfaces, to provide basic data for subsequent test case retrieval, supplementation and optimization.
[0025] In a preferred embodiment, after obtaining data in step S11, data preprocessing can be performed, including cleaning, transformation, and enhancement.
[0026] The data cleaning process focuses on removing data noise and correcting data biases. It uses a combination of automated algorithms and manual rule verification to accurately identify and remove duplicate records from multiple data sources. For different types of missing values (such as performance metrics missing in some call chain data or business tags not marked in code files), it uses mean imputation, median imputation, or interpolation based on adjacent data to fill in the missing values according to the business scenario. At the same time, it uses statistical methods such as the 3σ principle and box plot analysis to identify and process outliers that exceed the reasonable range, so as to avoid abnormal data interfering with the subsequent map construction.
[0027] The data conversion stage focuses on solving the problem of inconsistent formats among multiple data sources. The system will use preset format conversion rules to map all data into the system's standard structured data format, clarify the definition, type, and relationship of data fields, and provide a unified data foundation for subsequent node extraction and relationship construction.
[0028] The data augmentation process proactively supplements the missing key dependencies in the data based on business rules and domain knowledge.
[0029] Step S12: Extract class nodes, method nodes, interface nodes, and data structure nodes from the code data. Based on the code dependencies, construct relationship edges between each node and set the weights of the relationship edges to obtain the semantic graph.
[0030] This step begins with node extraction, primarily extracting four types of nodes: class nodes, method nodes, interface nodes, and data structure nodes. Class nodes mainly represent core code organization units in various programming languages, including Java classes, Python classes, and C++ classes. They are the basic carriers for encapsulating attributes and methods and implementing specific functional modules. Method nodes specifically refer to the concrete methods and functions defined in a class or module. They are the direct implementers of business logic, covering various specific functional logics such as data processing, business calculations, and external interactions. Interface nodes correspond to API interfaces and service interfaces in the system. They are the contract carriers for data interaction and function calls between different modules and services, clarifying the rules of interaction, parameter formats, and return result definitions. Data structure nodes focus on the important data carriers supporting the operation of business logic, including core entity classes, Data Transfer Objects (DTOs), configuration objects, and other key data structures. They are the core units for data flow and storage in the code.
[0031] In a preferred embodiment, the extracted class nodes, method nodes, interface nodes, and data structure nodes are labeled with attributes, including node ID, node type, code location, and business tags. The business tags are business semantics extracted from code comments and business documents.
[0032] Node IDs, as globally unique identifiers, ensure no duplication throughout the semantic graph, providing a unique index for node retrieval, related queries, and full lifecycle management. Node types clearly indicate the specific category to which the node belongs, including class, method, interface, data structure, etc. Code location accurately records the complete storage path (including directory level) and specific line number range of the code corresponding to the node in the project, enabling direct tracing from graph nodes to the original code. Business tags are business semantic identifiers extracted and standardized through natural language processing technology based on functional descriptions in code comments, scenario definitions in business requirement documents, and module divisions in architecture design documents. Examples include "user authentication verification," "order payment settlement," and "sensitive data encryption," allowing technical code nodes to be directly bound to actual business scenarios, providing key business-dimensional judgment criteria for impact path prediction under the semantic understanding strategy.
[0033] After extracting the nodes, it is necessary to construct the relationship edges between the nodes. In a preferred embodiment, this step includes: If a call relationship exists between two nodes, a call relationship edge is constructed between the two nodes. The call relationship is a core interaction form in the code execution process, specifically referring to the proactive call behavior between method nodes. For example, when method A executes specific business logic, it triggers the execution of method B through function call syntax. This relationship directly supports the step-by-step implementation and flow of business logic.
[0034] If an inheritance relationship exists between two nodes, an inheritance edge is constructed between the two nodes. Inheritance is a core feature of object-oriented programming, existing between class nodes. For example, class A reuses the attributes and methods of class B through inheritance and can extend new functionality on this basis. This relationship reflects the code reuse design and hierarchical structure.
[0035] If an implementation relationship exists between two nodes, then an implementation relationship edge is constructed between the two nodes. An implementation relationship means that class A completes the specific implementation according to the method specification defined by interface B.
[0036] If a usage relationship exists between two nodes, a usage relationship edge is constructed between the two nodes. A usage relationship specifically refers to the dependency behavior of a method node on a class node. For example, during the execution of method A, it may need to create an instance of class B, call a static property or non-static method of class B. This is a direct manifestation of resource dependencies in the code logic implementation process.
[0037] If a data flow relationship exists between two nodes, then a data flow relationship edge is constructed between the two nodes. The data flow relationship focuses on the path of data transmission between different nodes. For example, data is read and processed from data structure node A by method node B and then transmitted to interface node C for external output, or it flows between method nodes of different services.
[0038] After constructing the relationship edges, the weights of the relationship edges are set. In a preferred embodiment, this step includes: obtaining the test pass rate of the code path of each relationship edge from historical test data of the code data; obtaining the call frequency of the code path of each relationship edge in the production environment; reading the importance weight of each relationship edge from business documents and user configurations as the business importance; obtaining the historical change frequency of the code path of each relationship edge; and calculating the weight of the relationship edge based on the test pass rate, call frequency, business importance, and historical change frequency corresponding to the relationship edge.
[0039] The weight calculation formula is as follows: Weight = α × Test pass rate + β × Call frequency + γ × Business importance - δ × Historical change frequency Where α, β, γ, and δ are configurable parameters that satisfy α+β+γ-δ=1.
[0040] By extracting nodes, constructing relation edges, and configuring weights as described above, a semantic graph can be built. Preferably, this semantic graph can be a BAC-Graph semantic graph.
[0041] After completing step S12 to construct the semantic graph, reasoning analysis can be performed. Steps S13 and S14 use a multi-strategy entry identification method to identify the changed entry nodes, and step S15 executes the graph propagation algorithm to calculate the scope of influence.
[0042] Step S13: When a code change is detected, use a static analysis strategy to analyze the syntax structure and type information of the code change, use a dynamic analysis strategy to identify the actual call path based on historical call chain data, and use a semantic understanding strategy to analyze the semantic intent of the code change using a large language model.
[0043] The core of static analysis strategies is to analyze the syntactic structure and type information of code changes. Syntax analysis identifies modified method signatures and class definitions by parsing the abstract syntax tree (AST) of the changed code; type analysis analyzes interfaces and methods that may be affected by the changes based on the programming language's type system; and dependency analysis focuses on static dependencies between code, accurately identifying components that have direct dependencies on the changed code.
[0044] The dynamic analysis strategy relies on historical call chain data to identify the actual call paths corresponding to code changes. Specifically, it searches for paths containing changed code in historical call chain data through call chain matching; it uses frequency analysis to statistically analyze the occurrence frequency of each call path and prioritizes high-frequency paths; and it uses time analysis to consider the time distribution characteristics of call paths and accurately identify the most recently active paths.
[0045] The semantic understanding strategy leverages Large Language Models (LLMs) to parse the semantic intent of code changes. It analyzes the functional intent and business impact of the changed code through code understanding; retrieves semantically similar code snippets from the codebase through similarity analysis; and infers potential indirect impact paths based on code semantics through impact prediction.
[0046] Alternatively, the optimal strategy combination can be automatically selected based on machine learning models, or the strategy priority can be configured for different scenarios based on a rule engine.
[0047] Step S14: Based on the analysis results of the three strategies, identify the change entry nodes and construct a set of entry nodes.
[0048] After obtaining the analysis results of the three strategies above, a final score can be obtained through weighted fusion, and then the final set of change entry nodes can be derived based on the score. The score calculation formula is as follows: Final score = w1 × static analysis score + w2 × dynamic analysis score + w3 × semantic understanding score w1, w2, and w3 are weight parameters that can be flexibly configured according to the actual application scenario, and must satisfy the constraint condition w1+w2+w3=1 to ensure the scientific nature and consistency of the score calculation.
[0049] If a method undergoes code changes, after analysis using three strategies, its static analysis score is 85, its dynamic analysis score is 90, and its semantic understanding score is 88. With configured weights w1=0.3, w2=0.4, and w3=0.3 (satisfying 0.3+0.4+0.3=1), the method's final score is 0.3×85+0.4×90+0.3×88=25.5+36+26.4=87.9. If the entry node selection threshold is set to 80 points, this method will be included in the final list of change entry points.
[0050] Step S15: Calculate the probability of each node being affected based on the set of entry nodes, the semantic graph, and the preset propagation threshold, and obtain the impact analysis results.
[0051] The core function of the graph propagation algorithm is to propagate the impact of code changes in the BAC-Graph semantic graph, accurately calculating the probability of each node being affected. Its input includes three key types of information: the set of entry points for the change, E={e1,e2,...,en}; the BAC-Graph semantic graph G=(V,E,W) (where V is the set of nodes, E is the set of edges, and W is the weight matrix); and the propagation threshold θ.
[0052] In a preferred embodiment, the specific corrections to the graph propagation algorithm are as follows: S61. Set the initial probability of being affected by the entry node ei to 1, P(ei)=1.0, and set the initial probability of being affected by other nodes to 0, P(v)=0.0; integrate all entry nodes into a processing node queue Q.
[0053] S62. When queue Q is not empty, take a node from the processing node queue and use it as node u.
[0054] S63. For each neighbor node v of node u, calculate the propagation probability P(v|u) of node u to node v based on the weight of the relation edge, the probability of node u being affected, and the attenuation factor, as follows: P(v|u) = W(u,v) × P(u) × decay factor, where W(u,v) is the weight of the relationship edge between u and v, and P(u) is the probability that node u is affected.
[0055] S64. If the propagation probability P(v|u) of node u to node v is greater than the current affected probability P(v) of node v, then the propagation probability of node u to node v is assigned to the affected probability P(v) = P(v|u) of node v.
[0056] S65. If the probability P(v) of node v being affected is greater than the preset propagation threshold θ, then node v is placed into the processing node queue Q. S66. If the processing node queue is not empty, repeat steps S62 to S65; otherwise, execute S67. S67. Output all nodes whose probability of being affected is greater than the preset propagation threshold, and the probability of being affected corresponding to each node.
[0057] Furthermore, the probability calculation employs a Bayesian network model, with the following formula: P(Affected) = P(Change) × P(Propagation | Change) × P(Affect | Propagation) P(Change) is determined based on the type and scope of the code change, P(Propagation|Change) is calculated based on the edge weights and topology, and P(Impact|Propagation) is determined by historical impact data and business rules.
[0058] Step S16: Obtain test cases related to each affected node, execute tests according to the test cases, and obtain test results.
[0059] Alternatively, the graph propagation algorithm can be replaced by a graph propagation model based on a random walk algorithm or a deep learning model based on a graph neural network.
[0060] In a preferred embodiment, obtaining test cases associated with each affected node includes: retrieving test cases associated with the affected node from an existing test case library, and / or generating test cases using a large language model based on the code, business description, and test requirements of the affected node.
[0061] Test case retrieval involves filtering test cases related to the affected nodes from the existing test case library. It achieves precise location through three matching methods: code location matching to find test cases that cover the same code files; function matching to retrieve test cases that test the same business function; and dependency matching to find corresponding test cases that test related dependent components.
[0062] Test case generation supplements missing test cases using a large language model. Inputting the code of the affected node, business description, and test requirements, it outputs new test case code. At the same time, the generated test cases need to be subjected to syntax and logic verification to ensure that they meet the execution standards.
[0063] Alternatively, template-based test case generation methods or genetic algorithm-based test case optimization methods can be used to generate test cases.
[0064] After obtaining the test cases, the test cases are optimized by streamlining and adjusting the integrated test case set: removing test cases with duplicate functions, merging multiple test cases for the same function, and adjusting the test priority based on the probability of impact and business importance to improve the targeting of test execution.
[0065] Finally, the optimized test cases are transformed into contract test formats, including interface contract tests based on API interface definitions, data contract tests based on data structure definitions, and behavioral contract tests based on business rules, to ensure the compatibility of interactions between services.
[0066] The test execution adopts a parallel execution strategy. First, the execution order is determined according to the test dependencies. Then, independent test cases are grouped and executed in parallel. At the same time, the test execution status and resource usage are monitored in real time, and an automatic retry mechanism is supported when the test fails.
[0067] In a preferred embodiment, after obtaining the test results, the method further includes: Analyze the test results and update the weights of relation edges in the semantic graph based on the analysis results.
[0068] The results analysis includes test pass rate statistics, root cause analysis of failed test cases, assessment of factors affecting the accuracy of the analysis, and collection of system performance metrics. Based on the above analysis results, the system will undergo multi-dimensional optimization and updates, including updating the weights of BAC-Graph edges, adjusting the parameters of the inference model, optimizing the test generation strategy, and improving the entry point identification algorithm, thereby continuously improving system performance and analysis accuracy.
[0069] Suppose that in a microservice system, the `getUserInfo()` method of the user service is modified. The system will execute the following process: First, change detection is performed to accurately identify the modification of the `getUserInfo()` method. Then, the entry point identification stage is entered. Static analysis identifies other methods that directly call this method, and dynamic analysis searches the historical call chain for call paths containing this method. Semantic understanding is used to analyze the business functions that may be affected. Next, in the BAC-Graph semantic graph, the impact of the change is propagated from the `getUserInfo()` node, calculating the probability of being affected for related nodes such as the order service and payment service. Then, targeted test cases are generated for the user service, order service, and payment service, and these test cases are executed in parallel. Finally, analysis is conducted based on the test results to update and optimize the graph weights.
[0070] In practice, the timing of interactions between components is as follows: After a user submits a code change, the request is transmitted to the system through the API gateway, triggering the impact analysis process; the API gateway sends a data collection instruction to the data collector, which simultaneously collects code change data, builds test data, call chain data, and test case data from multiple data sources such as Git repositories, CI / CD systems, call chain tracing systems (such as Jaeger), and test case libraries; after completing data preprocessing, the data collector sends the standardized data to the graph builder; the graph builder updates the BAC-Graph semantic graph based on the preprocessed data and stores the updated graph data in the graph storage module; the graph builder sends a graph update notification to the inference analyzer, initiating the impact scope inference process.
[0071] After receiving the graph update notification, the inference analyzer retrieves the latest BAC-Graph semantic graph from the graph storage; the inference analyzer sequentially executes multi-strategy entry point identification (static analysis, dynamic analysis, semantic understanding) and graph propagation algorithm to calculate the probability of each node being affected; the inference analyzer sends the final impact range result to the test generator to trigger the test case generation process.
[0072] After receiving the impact scope results, the test generator first retrieves existing test cases related to the affected nodes from the test case library. For scenarios with insufficient coverage, the test generator generates supplementary test cases through a large language model and completes test case deduplication, merging, and priority adjustment. The test generator sends the optimized test case set to the test executor. The test executor arranges the execution order based on the dependency relationship of the test cases, groups independent test cases for parallel execution, and monitors the execution status in real time. The test executor sends the test execution results (including pass status and failure details) to the result analyzer.
[0073] The results analyzer performs a comprehensive analysis of the received test results, including test pass rate statistics, root cause localization of failed test cases, impact analysis accuracy assessment, and system performance indicator collection. Based on the analysis results, the results analyzer sends weight update instructions to the graph storage and model parameter optimization suggestions to the inference analyzer. The results analyzer generates impact analysis reports and test reports, which are fed back to the user through the API gateway. The user can view the final scope of the change impact, test execution results, and system improvement suggestions through the API gateway.
[0074] If the test executor detects a test execution failure, it immediately sends a failure notification to the test generator. The test generator regenerates an adapted test case based on the reason for the failure and resends it to the test executor. The test executor initiates an automatic retry mechanism to re-execute the test case until the test is completed or the preset number of retries is reached. Finally, the retried test results are sent to the result analyzer to ensure a closed-loop process.
[0075] The technical solution of this invention has the following beneficial effects: First, the unified modeling of the BAC-Graph semantic graph integrates production call chains, code semantics, and business process information into the same semantic graph for the first time, effectively solving the problem of scattered multi-source data in existing technologies; Second, the multi-strategy entry point identification method comprehensively covers the entry point identification scenario of code changes by integrating three strategies: static analysis, dynamic analysis, and semantic understanding, significantly improving the accuracy of impact analysis; Third, the influence propagation algorithm based on the probabilistic graphical model calculates the probability of nodes being affected by a combination of Bayesian networks and graph propagation algorithms, achieving higher accuracy compared to traditional simple graph traversal methods; Fourth, the intelligent test case generation mechanism automatically generates targeted test cases based on a large language model, supporting various test types such as unit testing, integration testing, and contract testing; Fifth, the adaptive optimization mechanism continuously updates the graph weights and inference model parameters based on test results, achieving adaptive adjustment to changes in the codebase.
[0076] This technical solution offers superior accuracy in impact analysis. Existing technologies rely solely on dynamic call chain data, making it difficult to consider both static dependencies and semantic intent. In contrast, this invention integrates three dimensions: static analysis, dynamic analysis, and semantic understanding. It can comprehensively capture the direct and indirect impacts of code changes, achieving an impact analysis accuracy rate of over 92%.
[0077] The test coverage is more comprehensive. Existing technologies rely on human experience to generate test cases, which is prone to missing key scenarios. This invention automatically generates targeted test cases based on accurate impact analysis, increasing the test coverage rate from the industry average of 65% to over 95%, ensuring that no affected functional modules are missed.
[0078] The testing efficiency is significantly improved. Existing technologies require the execution of a large number of redundant test cases, which wastes computing resources and prolongs the testing cycle. This invention optimizes and eliminates invalid test cases through intelligent test case optimization, reducing test execution time by 60% and reducing the defect miss rate from 15% to below 3%.
[0079] The system is highly adaptive. Existing technologies lack a self-learning mechanism and cannot adapt to dynamic changes in the codebase. This invention continuously updates the BAC-Graph weights and inference model parameters based on test results, enabling adaptive adjustments to the codebase iterations and continuously improving the accuracy of impact analysis.
[0080] Adapting to complex architecture scenarios, existing technologies are limited in their effectiveness under the complex dependencies of microservice architectures and distributed systems. This invention can efficiently parse cross-service dependencies and data flow links, making it particularly suitable for such complex architectures and effectively solving the application bottlenecks of existing technologies.
[0081] In another embodiment, a system for identifying the impact of code changes and executing automated tests is provided, comprising at least: The application service layer includes a data acquisition module, which is responsible for collecting data from data sources such as Git repositories, CI / CD systems, and call chain tracing systems to obtain code data, code dependencies, and call chain data.
[0082] The graph construction module builds and maintains the BAC-Graph semantic graph based on the collected data. It is used to extract class nodes, method nodes, interface nodes and data structure nodes from code data, construct relationship edges between each node according to code dependencies, and set the weights of the relationship edges to obtain the semantic graph.
[0083] The inference and analysis module executes multi-strategy entry point identification and graph propagation algorithms to calculate the scope of impact. When a code change is detected, it uses a static analysis strategy to analyze the syntax structure and type information of the code change, a dynamic analysis strategy to identify the actual call path based on historical call chain data, and a semantic understanding strategy to analyze the semantic intent of the code change using a large language model. Based on the analysis results of the three strategies, the change entry point node is identified, and an entry point node set is constructed. Based on the entry point node set, semantic graph, and preset propagation threshold, the probability of each node being affected is calculated to obtain the impact analysis results.
[0084] The test management module manages the lifecycle of test cases, including generation, optimization, and execution.
[0085] The execution orchestration module orchestrates the test execution order, supports parallel test execution, and is used to obtain test cases related to each affected node, execute tests based on the test cases, and obtain test results.
[0086] The system also includes: The data processing layer includes a data cleaning module, a feature extraction module, and a model training module. The data cleaning module is used to remove duplicate values, process missing values, and handle outliers from the acquired raw data. The feature extraction module is used to extract valid data from the acquired raw data. The model training module is used to train the model required by the application service layer based on historical data.
[0087] The system also includes: The front-end layer provides the user interface. It comprises three components: a web management interface, an API gateway, and a command-line tool. The web management interface, developed using the React framework, provides visualization of impact analysis results and system configuration. The API gateway, built on Spring Cloud Gateway, offers a unified REST API interface to support external interactions. The command-line tool, developed in Python, supports scripted operations and batch processing.
[0088] The storage layer stores data generated during the execution of the application service layer. It employs a multi-database architecture: the graph database cluster uses Neo4j to store the BAC-Graph semantic graph, supporting efficient graph query and traversal operations; the relational database uses a MySQL cluster to store structured data such as project information and user configurations; the cache cluster uses Redis for fast access to hot data and intermediate results; and object storage uses MinIO / S3 to manage test case files and log data. Alternatively, an in-memory graph database (such as JanusGraph) combined with distributed storage can be used, suitable for extremely large codebases; or, a relational database (such as MySQL) can be used to store the graph structure via adjacency lists, which is less costly.
[0089] The message layer is used to transmit event streams, providing asynchronous communication channels for internal system components. The message layer is centered around the Kafka message queue and the internal event bus: the Kafka cluster specifically handles high-throughput data streams such as code change events and test execution results; the internal event bus is responsible for asynchronous communication between internal system components, ensuring efficient and smooth collaboration between modules.
[0090] The monitoring layer is used to collect system performance metrics and manage logs. It constructs a complete end-to-end monitoring system: metric monitoring uses Prometheus to collect system performance metrics; log collection leverages the ELK Stack (Elasticsearch, Logstash, Kibana) for log management and analysis; the tracing system uses Jaeger to implement distributed tracing; and the alerting system triggers intelligent alerts through AlertManager to respond promptly to anomalies.
[0091] It is understood that the same or similar parts in the above embodiments can be referred to each other, and the contents not described in detail in some embodiments can be referred to the same or similar contents in other embodiments.
[0092] It should be noted that in the description of this invention, the terms "first," "second," etc., are used for descriptive purposes only and should not be construed as indicating or implying relative importance. Furthermore, in the description of this invention, unless otherwise stated, "a plurality of" means at least two.
[0093] Any process or method description in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process, and the scope of the preferred embodiments of the invention includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functions involved, as will be understood by those skilled in the art to which embodiments of the invention pertain.
[0094] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0095] Those skilled in the art will understand that all or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, the program includes one or a combination of the steps of the method embodiments.
[0096] Furthermore, the functional units in the various embodiments of the present invention can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium.
[0097] The storage media mentioned above can be read-only memory, disk, or optical disk, etc.
[0098] In the description of this specification, references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of the invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.
[0099] Although embodiments of the present invention have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present invention. Those skilled in the art can make changes, modifications, substitutions and variations to the above embodiments within the scope of the present invention.
Claims
1. A method for identifying the impact of code changes and executing automated tests, characterized in that, include: Retrieve code data, code dependencies, and call chain data; Extract class nodes, method nodes, interface nodes, and data structure nodes from the code data. Based on the code dependencies, construct relationship edges between the nodes and set the weights of the relationship edges to obtain a semantic graph. When code changes are detected, static analysis strategies are used to analyze the syntax structure and type information of the code changes, dynamic analysis strategies are used to identify the actual call paths based on historical call chain data, and semantic understanding strategies are used to analyze the semantic intent of the code changes using a large language model. Based on the analysis results of the three strategies, the change entry nodes are identified, and a set of entry nodes is constructed. Based on the set of entry nodes, semantic graph, and preset propagation threshold, the probability of each node being affected is calculated to obtain the impact analysis results; Obtain the test cases associated with each affected node, execute the tests according to the test cases, and obtain the test results.
2. The method according to claim 1, characterized in that, Based on the set of entry nodes, the semantic graph, and the preset propagation threshold, the probability of each node being affected is calculated, including: S61. Set the initial probability of the entry node being affected to 1, and set the initial probability of other nodes being affected to 0; integrate all entry nodes into a processing node queue. S62. Take a node from the processing node queue and designate it as node u; S63. For each neighbor node v of node u, calculate the propagation probability of node u to node v based on the weight of the relation edge, the probability of node u being affected, and the decay factor. S64. If the propagation probability of node u to node v is greater than the influence probability of node v, then the propagation probability of node u to node v is assigned to the influence probability of node v. S65. If the probability of node v being affected is greater than the preset propagation threshold, then node v is placed into the processing node queue. S66. If the processing node queue is not empty, repeat steps S62 to S65; otherwise, execute S67. S67. Output all nodes whose probability of being affected is greater than the preset propagation threshold, and the probability of being affected corresponding to each node.
3. The method according to claim 1, characterized in that, Also includes: The extracted class nodes, method nodes, interface nodes, and data structure nodes are labeled with attributes, including node ID, node type, code location, and business tags. The business tags are business semantics extracted from code comments and business documents.
4. The method according to claim 1, characterized in that, Based on code dependencies, construct relationship edges between the nodes, including: If a call relationship exists between two nodes, then construct a call relationship edge between the two nodes; If an inheritance relationship exists between two nodes, then an inheritance relationship edge is constructed between the two nodes; If an implementation relationship exists between two nodes, then an implementation relationship edge is constructed between the two nodes; If there is a usage relationship between two nodes, then construct a usage relationship edge between the two nodes; If a data flow relationship exists between two nodes, then construct a data flow relationship edge between the two nodes.
5. The method according to claim 1, characterized in that, Set the weights of the relationship edges, including: From historical test data of the code data, obtain the test pass rate of the code path of each relationship edge; obtain the call frequency of the code path of each relationship edge in the production environment; read the importance weight of each relationship edge from business documents and user configurations as the business importance; obtain the historical change frequency of the code path of each relationship edge; The weight of a relation edge is calculated based on its test pass rate, call frequency, business importance, and historical change frequency.
6. The method according to claim 1, characterized in that, Obtain the test cases associated with each affected node, including: Retrieve test cases related to the affected nodes from the existing test case library, and / or generate test cases using a large language model based on the code, business description, and test requirements of the affected nodes.
7. The method according to claim 1, characterized in that, Also includes: Analyze the test results and update the weights of relation edges in the semantic graph based on the analysis results.
8. A system for identifying the impact of code changes and automating test execution, characterized in that, At least including: The application service layer includes: a data acquisition module, used to acquire code data, code dependency relationships, and call chain data; The graph construction module is used to extract class nodes, method nodes, interface nodes, and data structure nodes from code data. Based on code dependencies, it constructs relationship edges between nodes and sets the weights of these relationship edges to obtain a semantic graph. The reasoning and analysis module is used to analyze the syntax structure and type information of the code change using static analysis strategy, identify the actual call path based on historical call chain data using dynamic analysis strategy, and analyze the semantic intent of the code change using a large language model using semantic understanding strategy when code changes are detected. Based on the analysis results of the three strategies, the change entry node is identified and a set of entry nodes is constructed. Based on the set of entry nodes, semantic graph and preset propagation threshold, the probability of each node being affected is calculated to obtain the impact analysis results. The test management module is used to manage the lifecycle of test cases; The execution orchestration module is used to obtain test cases related to each affected node, execute tests based on the test cases, and obtain test results.
9. The system according to claim 8, characterized in that, Also includes: The data processing layer includes a data cleaning module, a feature extraction module, and a model training module; The data cleaning module is used to remove duplicate values, process missing values and outliers from the acquired raw data. The feature extraction module is used to extract valid data from the acquired raw data; The model training module is used to train the models required by the application service layer based on historical data.
10. The system according to claim 8, characterized in that, Also includes: The front-end layer is used to provide the user interface. The storage layer is used to store data generated during the execution of the application service layer. The message layer is used to transmit event streams and provide asynchronous communication channels for internal system components; The monitoring layer is used to collect system performance metrics and manage logs.
Citation Information
Cited By
Development man-hour estimation method and system based on function dependence graph
CN122114881A
Change impact analysis method combined with natural language processing
CN122242524A