Test case generation method, device, medium, processor and system
By constructing a weighted directed fusion graph and using AI models to generate test cases, the problems of incomplete test coverage and resource waste in existing technologies are solved, enabling dynamic response to complex business changes and accurate test path identification.
Patent Information
- Application Number
- CN202611485102.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-22
- Publication Date
- 2026-11-27
AI Technical Summary
Existing test case generation solutions cannot dynamically generate new test logic to cope with complex business changes, resulting in incomplete test coverage and wasted resources. Furthermore, the lack of a weighting mechanism based on historical defect data makes it impossible to distinguish between critical paths and edge paths.
By constructing a directed static dependency graph and a directed historical defect propagation graph, a weighted fusion algorithm is used to generate a weighted directed fusion graph. Based on this graph, multiple test cases and their corresponding priorities are generated. AI models and large language models are used to generate test code for the changed logic.
It enables dynamic response to complex business changes, accurately identifies high-risk paths, optimizes test resource allocation, improves test coverage and efficiency, and avoids cold start and overfitting issues.
Smart Images

Figure CN123178276A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software testing technology, and more specifically, to a method, apparatus, medium, processor, and system for generating test cases. Background Technology
[0002] Existing regression testing methods based on code change impact analysis mainly rely on static code structures (such as call graphs and dependency graphs) to extrapolate impact propagation. This static perspective cannot identify implicit impact paths generated through data flow, configuration files, or message queues, resulting in incomplete test coverage. At the same time, existing technologies treat all dependency edges as equally weighted connections, lacking a weighting mechanism based on historical defect data (such as defect frequency, severity level, and repair cycle), and cannot distinguish between critical paths and marginal paths. This leads to high-risk paths not being prioritized for testing while low-probability paths waste resources. Furthermore, existing solutions only select test cases from existing test case libraries, failing to dynamically generate new test logic to cope with complex business changes, and the test results do not update the impact model in reverse. Summary of the Invention
[0003] The main purpose of this application is to provide a method, apparatus, medium, processor and system for generating test cases, so as to at least solve the problem that existing test case generation schemes only select test cases from existing test case libraries and cannot dynamically generate new test logic to cope with complex business changes.
[0004] To achieve the above objectives, according to one aspect of this application, a method for generating test cases is provided, comprising: acquiring code commit events, parsing a list of changed files and the granularity of changes, and outputting a structured change event object; and using an abstract syntax tree parser to parse the source code of the structured change event object, identify the call relationships between modules, classes, and methods to construct a directed static dependency graph, wherein nodes represent code units and edges represent call or dependency relationships; acquiring historical defect data, the historical defect data including defect IDs, associated code changes, and repair records; based on the correlation analysis of code changes, inferring the propagation path of defects between modules to construct a directed historical defect propagation graph, and assigning initial weights to the edges in the graph based on defect severity level, repair cycle, and propagation frequency; performing graph alignment and node matching between the directed static dependency graph and the directed historical defect propagation graph, and generating a weighted directed fusion graph using a weighted fusion algorithm; and generating multiple test cases and corresponding priorities based on the weighted directed fusion graph.
[0005] Optionally, a weighted fusion algorithm is used to generate a weighted directed fusion graph, including:
[0006] according to Determine the edge weights of the weighted directed fusion graph;
[0007] in, Let the edge weights be those between node u and node v in the weighted directed fusion graph. Let U be the edge weight from node u to node v in the directed static dependency graph. Let α be the edge weight from node u to node v in the directed historical defect propagation graph, and let α and β be weight coefficients, with the sum of α and β being 1.
[0008] Optionally, after generating a weighted directed fusion graph using a weighted fusion algorithm, the method further includes:
[0009] according to Determine the edge weights of the normalized weighted directed fusion graph;
[0010] in, The normalized edge weights from node u to node v in the weighted directed fusion graph are: Let be the minimum value of the edge weights in the weighted directed fusion graph. This represents the maximum value of the edge weights in the weighted directed fusion graph.
[0011] Optionally, a directed historical defect propagation graph is constructed, including:
[0012] according to Determine the edge weights of the directed historical defect propagation graph;
[0013] in, Let be the edge weight from node u to node v in the directed historical defect propagation graph. Let be the severity level coefficient of the i-th defect. denoted as the defect repair cycle, and n as the total number of defects.
[0014] Optionally, generating multiple test cases and corresponding priorities based on the weighted directed fusion graph includes: performing multi-hop propagation on the weighted directed fusion graph with the change point as the root node; determining the influence strength as the product of the influence value of the upstream node and the product of the attenuation edge weights during each hop propagation: the product of the attenuation edge weights is the product of the normalized edge weights of the weighted directed fusion graph and the attenuation factor; determining the set of affected modules and the influence weights, wherein nodes greater than or equal to a threshold are included in the set of affected modules; and generating multiple test cases and corresponding priorities based on the set of affected modules and the weighted directed fusion graph.
[0015] Optionally, generating multiple test cases and corresponding priorities based on the affected module set and the weighted directed fusion graph includes: processing the affected module set and the weighted directed fusion graph using an AI model to generate multiple test cases and corresponding priorities.
[0016] According to another aspect of this application, a test case generation apparatus is provided, comprising: a first acquisition unit, configured to acquire code commit events, parse a list of changed files and change granularity, and output a structured change event object; and use an abstract syntax tree parser to parse the source code of the structured change event object, identify the call relationships between modules, classes and methods, to construct a directed static dependency graph, wherein nodes represent code units and edges represent call or dependency relationships; a second acquisition unit, configured to acquire historical defect data, the historical defect data including defect IDs, associated code changes and repair records; based on the association analysis of code changes, inferring the propagation path of defects between modules to construct a directed historical defect propagation graph, and assigning initial weights to the edges in the graph based on defect severity level, repair cycle and propagation frequency; a first processing unit, configured to perform graph alignment and node matching on the directed static dependency graph and the directed historical defect propagation graph, and generate a weighted directed fusion graph using a weighted fusion algorithm; and a second processing unit, configured to generate multiple test cases and corresponding priorities based on the weighted directed fusion graph.
[0017] According to another aspect of this application, a computer-readable storage medium is provided, the computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform any of the methods described.
[0018] According to another aspect of this application, a processor is provided for running a program, wherein the program, when running, performs any of the methods described.
[0019] According to another aspect of this application, a test case generation system is provided, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs including methods for performing any of the methods described.
[0020] Applying the technical solution of this application, the static dependency graph reveals the theoretical call relationships between code, but cannot reflect the actual probability of fault propagation; the historical defect graph reflects the actual fault paths, but may miss implicit dependencies that have not yet failed. The fused graph contains both theoretical reachability and actual risk, and can more accurately identify high-risk paths that, although not directly called, have implicit dependencies such as data coupling and configuration sharing, reducing the risk of missed detections. Through weighted fusion, each edge in the graph not only indicates whether it is connected, but also quantifies the risk intensity of the connection. High-weight edges represent paths that have frequently failed in the past or have high repair costs, while low-weight edges represent stable or low-risk paths. This allows the system to perform accurate risk ranking based on quantified weights, rather than treating all affected modules equally, thereby optimizing the allocation of test resources. For new modules or new functions that lack historical defect data, the static dependency part can still provide basic impact range analysis; for mature modules, historical defect weights provide stronger guidance, avoiding the cold start problem or overfitting problem caused by a single data source. The fusion graph, as the input to the subsequent graph neural network and test path ranking model, provides a richer and more realistic feature space, thereby solving the problem that existing test case generation schemes only select test cases from the existing test case library and cannot dynamically generate new test logic to cope with complex business changes. Attached Figure Description
[0021] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings:
[0022] Figure 1 A flowchart illustrating a method for generating test cases according to an embodiment of this application is shown.
[0023] Figure 2 A structural block diagram of a test case generation apparatus provided according to an embodiment of this application is shown. Detailed Implementation
[0024] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0025] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0027] As described in the background section, existing regression testing methods based on code change impact analysis mainly rely on static code structures (such as call graphs and dependency graphs) to extrapolate impact propagation. This static perspective cannot identify implicit impact paths generated through data flows, configuration files, or message queues, resulting in incomplete test coverage. Furthermore, existing technologies treat all dependency edges as equally weighted connections, lacking a weighting mechanism based on historical defect data (such as defect frequency, severity level, and repair cycle), and cannot distinguish between critical and marginal paths. This leads to high-risk paths not being prioritized for testing while low-probability paths waste resources. In addition, existing solutions only select test cases from an existing test case library, failing to dynamically generate new test logic to address complex business changes, and the test results do not update the impact model in reverse. To address the problem that existing test case generation solutions only select test cases from an existing test case library and cannot dynamically generate new test logic to address complex business changes, embodiments of this application provide a test case generation method, apparatus, medium, processor, and system.
[0028] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention.
[0029] This embodiment provides a method for generating test cases that run on a mobile terminal, computer terminal, or similar computing device. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Also, although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a different order than that shown here.
[0030] Figure 1 This is a flowchart of a test case generation method according to an embodiment of this application. Figure 1 As shown, the method includes the following steps:
[0031] Step S101: Obtain code commit events, parse the list of changed files and the granularity of changes, and output a structured change event object; and use an abstract syntax tree parser to parse the source code of the above structured change event object, identify the calling relationships between modules, classes and methods, so as to construct a directed static dependency graph, where nodes represent code units and edges represent calling or dependency relationships.
[0032] Code change input module: This module integrates with version control systems; it captures code commit events in real time, extracting metadata such as change details, committer, time, and branch; and it structures the change information to serve as the trigger source for the entire system workflow. The specific implementation is as follows:
[0033] Triggered by continuous integration / continuous delivery pipeline tools; Change resolution: Use code management tools to obtain a list of change files; Use an abstract syntax tree parser to analyze the granularity of code changes in languages such as Java / Python (class, method, line level); Output JSON structured data.
[0034] Static dependency analysis module: Constructs a static code dependency graph within the project, identifying the call relationships between modules, classes, and methods; providing a basic topology structure for subsequent impact propagation analysis. The specific implementation is as follows:
[0035] The source code is parsed using an abstract syntax tree parser, which constructs control flow graphs and call graphs; it supports cross-file and cross-module dependency identification; dependency graph construction: nodes represent methods or classes; edges represent call relationships with direction (A→B means A calls B); and it labels call frequency, parameter complexity, and whether it is asynchronous, etc.; it uses a graph database for storage; update mechanism: incremental update, only re-parses changed files, improving efficiency.
[0036] Step S102: Obtain historical defect data, which includes defect ID, associated code changes and repair records; based on the association analysis of code changes, infer the propagation path of defects between modules to construct a directed historical defect propagation graph, and assign initial weights to the edges in the graph based on defect severity level, repair cycle and propagation frequency.
[0037] Here, the edges in the historical defect propagation graph are assigned initial weights based on the defect severity level, repair cycle, and propagation frequency.
[0038] Step S103: Align the above directed static dependency graph and the above directed historical defect propagation graph with nodes and perform graph matching, and use a weighted fusion algorithm to generate a weighted directed fusion graph.
[0039] Step S104: Generate multiple test cases and their corresponding priorities based on the weighted directed fusion graph described above.
[0040] Subsequently, test cases can be executed according to priority from high to low. This application utilizes a large language model as the generation engine after generating the weighted directed fusion graph and the set of affected modules. This engine can understand the specific semantics of code changes (such as newly added business rules and modified calculation logic), and, combined with the project's existing coding style and test templates, generates entirely new unit test code (such as boundary value tests and abnormal path tests) in real time, specifically targeting the changed logic. This generation method is no longer limited by the accumulation of historical test cases, and can dynamically respond to complex business changes that have never occurred before, filling gaps in test coverage.
[0041] In this application, the static dependency graph reveals the theoretical call relationships between code segments but fails to reflect the actual probability of fault propagation; the historical defect graph reflects actual fault paths but may miss implicit dependencies that have not yet failed. The fused graph simultaneously includes both theoretical reachability and actual risk, enabling more accurate identification of high-risk paths that, while not directly called, have implicit dependencies such as data coupling and configuration sharing, reducing the risk of missed detections. Through weighted fusion, each edge in the graph not only indicates whether it is connected but also quantifies the risk intensity of the connection. High-weighted edges represent paths that have historically frequently failed or have high repair costs, while low-weighted edges represent stable or low-risk paths. This allows the system to perform accurate risk ranking based on quantified weights, rather than treating all affected modules equally, thereby optimizing test resource allocation. For new modules or new features lacking historical defect data, the static dependency part can still provide basic impact range analysis; for mature modules, historical defect weights provide stronger guidance, avoiding cold start or overfitting problems caused by a single data source. The fusion graph, as the input to the subsequent graph neural network and test path ranking model, provides a richer and more realistic feature space, thereby solving the problem that existing test case generation schemes only select test cases from the existing test case library and cannot dynamically generate new test logic to cope with complex business changes.
[0042] Optionally, a weighted fusion algorithm is used to generate a weighted directed fusion graph, including:
[0043] according to Determine the edge weights of the weighted directed fusion graph;
[0044] in, Let the edge weights from node u to node v in the aforementioned weighted directed fusion graph be... Let U be the edge weights from node u to node v in the above directed static dependency graph. Let α and β be the edge weights from node u to node v in the directed historical defect propagation graph described above, where α and β are weight coefficients and the sum of α and β is 1.
[0045] For new modules or modules without historical defect records, relying solely on historical data can lead to missing or zero weights, making risk assessment impossible. Introducing static dependency weights as a foundation (such as default weights) ensures that even in the absence of historical failure data, the system can still identify potentially impactful paths based on the code structure, guaranteeing the completeness of the analysis. Static dependency graphs often contain a large number of low-frequency calls or non-critical paths; treating all of them as high-risk would lead to a waste of testing resources. Introducing historical defect weights (such as assigning high weights to high severity levels and short fix cycles) can filter out low-risk dependencies, accurately focusing on critical paths that have frequently failed or had a far-reaching impact in the past, improving the targeting of testing. By dynamically adjusting the weight coefficients (α and β), the model becomes adaptive.
[0046] The values of α and β are dynamically adjusted according to the project stage. In the early stage of the project or the development stage of a new module, the reliability of static dependencies is higher, and the value of α is larger (e.g., 0.7, in which case β is 0.3); in the mature stage of the project or the maintenance stage, historical defect data is more valuable for reference, and the value of β is larger (e.g., 0.6, in which case α is 0.4).
[0047] Optionally, after generating the weighted directed fusion graph using a weighted fusion algorithm, the above method further includes:
[0048] according to Determine the edge weights of the normalized weighted directed fusion graph.
[0049] in, The normalized weighted directed fusion graph above contains the edge weights from node u to node v. This represents the minimum value of the edge weights in the aforementioned weighted directed fusion graph. This represents the maximum value of the edge weights in the aforementioned weighted directed fusion graph.
[0050] The original weights may be composed of different sources (e.g., call frequency as integers, repair cycle as days, severity level as discrete coefficients), with huge differences in dimensions and orders of magnitude. Normalization maps all weights to a uniform interval (e.g., [0,1]), eliminating the influence of numerical magnitude on subsequent calculations and making features of different dimensions comparable. Downstream graph neural networks or ranking algorithms are usually sensitive to the numerical range of the input data. The more concentrated distribution of normalized data helps avoid problems such as gradient vanishing or exploding, improves the stability and convergence speed of model training, and ensures the accuracy of risk score calculation. The standardized weights have clear physical meaning (e.g., 0.8 represents relatively high risk, 0.1 represents relatively low risk). This makes setting a uniform impact threshold (e.g., 0.5) more intuitive, facilitating the system to automatically filter low-impact paths and select truly high-risk modules that need to be tested.
[0051] Optionally, a directed historical defect propagation graph is constructed, including:
[0052] according to Determine the edge weights of the directed historical defect propagation graph;
[0053] in, Let the edge weights from node u to node v in the directed historical defect propagation graph described above be... Let be the severity level coefficient of the i-th defect. denoted as the defect repair cycle, and n as the total number of defects.
[0054] The severity rating directly reflects the impact of a fault on business operations (e.g., a high weight for a fatal defect), while the remediation period reflects the difficulty and duration of fault handling. Combining these two factors allows the system to automatically identify critical propagation paths that are highly damaging and difficult to fix. This prioritizes coverage of these high-risk areas with limited testing resources, significantly improving the return on investment in testing. Focusing solely on the number of defects may overlook the destructive power of individual defects, and focusing solely on the severity rating may ignore frequently occurring minor issues. Introducing the remediation period as a weighting factor allows us to capture chronic fault paths that, while not fatal, consume significant R&D resources and lead to long-term system instability, making the fault map more accurately reflect the system's health pain points.
[0055] Optionally, multiple test cases and corresponding priorities are generated based on the aforementioned weighted directed fusion graph, including: performing multi-hop propagation on the aforementioned weighted directed fusion graph with the change point as the root node; determining the influence strength as the product of the influence value of the upstream node and the product of the attenuation edge weights during each hop propagation: the product of the attenuation edge weights is the product of the normalized edge weights of the aforementioned weighted directed fusion graph and the attenuation factor; determining the set of affected modules and the influence weights, wherein nodes greater than or equal to a threshold are included in the set of affected modules; and generating multiple test cases and corresponding priorities based on the aforementioned set of affected modules and the aforementioned weighted directed fusion graph.
[0056] Through a multi-hop propagation algorithm, the system is no longer limited to directly affected modules, but can trace indirect dependencies and deep connections along weighted edges. Combined with normalized edge weights, the algorithm can quantify the attenuation or amplification effect of risk during propagation, thus accurately identifying those implicitly high-risk modules that, although not directly modified, are highly susceptible to impact due to strong coupling relationships, overcoming the shortcomings of traditional static analysis that only focuses on direct calls. By calculating the specific "impact strength value" of each node, the system assigns a quantified risk score to each affected module. This numerical-based sorting mechanism breaks the limitations of traditional testing's equal treatment or simple classification, automatically prioritizing high-risk, high-impact modules and their related test cases, ensuring the verification of the core business logic in the shortest time and improving defect discovery efficiency. A threshold filtering mechanism is set to automatically remove low-priority nodes with impact strength below the threshold. This means the system can intelligently shield edge modules with extremely low risk and negligible impact on overall system quality, avoiding wasting computational resources and time on low-value test paths, thereby maximizing the simplification of the test scope and improving the execution speed of regression testing while ensuring complete test coverage. The introduction of the attenuation factor simulates the physical law that risk naturally decreases as the dependency level increases, enabling the algorithm to both cover critical deep dependencies and prevent test explosion caused by excessive risk dispersion. This mechanism makes the generated test case set both targeted (focusing on high-risk paths) and scalable (adapting to call chains of different depths), achieving dynamic balance and optimization of the testing strategy.
[0057] Optionally, multiple test cases and corresponding priorities are generated based on the aforementioned set of affected modules and the aforementioned weighted directed fusion graph, including: using an AI model to process the aforementioned set of affected modules and the aforementioned weighted directed fusion graph to generate multiple test cases and corresponding priorities.
[0058] The process of generating test cases and priorities based on AI models is as follows:
[0059] Data vectorization and feature extraction: The weighted directed graph and the set of affected modules are transformed into a numerical form that can be processed by the AI model. Node features (such as historical defect density, code complexity, and change type) and edge features (such as fusion weights and call frequency) are extracted to construct the adjacency matrix and feature matrix of the graph. For each affected module, a local subgraph containing its dependencies is extracted and used as model input.
[0060] Risk scoring and ranking based on graph neural networks: A local subgraph is input into a graph neural network. The model aggregates neighbor node information through an attention mechanism to learn the implicit risk propagation patterns between modules. After multiple layers of message passing, it outputs a risk embedding vector for each affected node. A fully connected layer maps the embedding vector to a specific risk probability score. Finally, the affected modules are ranked in descending order based on the risk scores, generating a test path sequence executed according to the high-risk priority principle.
[0061] Test case generation based on a large language model: For top-ranked critical test paths, a structured cue word context is constructed. This context includes: changed code snippets, interface definitions of affected modules, dependencies, and existing test style templates for the project. This context is then input into the large language model, and the instruction model generates unit test code covering normal, abnormal, and boundary scenarios.
[0062] Post-processing and injection: Static syntax validation, dependency checks, and deduplication are performed on the test code generated from the large language model. If syntax errors are found, a self-correction mechanism is triggered to regenerate the code. Test code that passes validation is marked with the corresponding high-priority tag and automatically injected into the project's test suite, where it is executed with the subsequent CI / CD (Continuous Integration / Continuous Delivery) pipeline.
[0063] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0064] This application also provides a test case generation apparatus. It should be noted that the test case generation apparatus of this application can be used to execute the test case generation method provided in this application. This apparatus is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0065] The following describes the test case generation apparatus provided in the embodiments of this application.
[0066] Figure 2 This is a structural block diagram of a test case generation apparatus according to an embodiment of this application. Figure 2As shown, the device includes: a first acquisition unit 21, used to acquire code commit events, parse the list of changed files and the granularity of changes, and output a structured change event object; and use an abstract syntax tree parser to parse the source code of the structured change event object, identify the calling relationships between modules, classes and methods, so as to construct a directed static dependency graph, wherein nodes represent code units and edges represent calling or dependency relationships; a second acquisition unit 22, used to acquire historical defect data, including defect IDs, associated code changes and repair records; based on the correlation analysis of code changes, inferring the propagation path of defects between modules, so as to construct a directed historical defect propagation graph, and assigning initial weights to the edges in the graph based on defect severity level, repair cycle and propagation frequency; a first processing unit 23, used to perform graph alignment and node matching on the directed static dependency graph and the directed historical defect propagation graph, and use a weighted fusion algorithm to generate a weighted directed fusion graph; and a second processing unit 24, used to generate multiple test cases and corresponding priorities based on the weighted directed fusion graph.
[0067] Optionally, the first processing unit includes:
[0068] The first processing module is used to... Determine the edge weights of the weighted directed fusion graph;
[0069] in, Let the edge weights from node u to node v in the aforementioned weighted directed fusion graph be... Let U be the edge weights from node u to node v in the above directed static dependency graph. Let α and β be the edge weights from node u to node v in the directed historical defect propagation graph described above, where α and β are weight coefficients and the sum of α and β is 1.
[0070] Optionally, the above-mentioned device further includes:
[0071] The third processing unit is used to generate a weighted directed fusion graph using a weighted fusion algorithm, based on... Determine the edge weights of the normalized weighted directed fusion graph.
[0072] in, The normalized weighted directed fusion graph above contains the edge weights from node u to node v. This represents the minimum value of the edge weights in the aforementioned weighted directed fusion graph. This represents the maximum value of the edge weights in the aforementioned weighted directed fusion graph.
[0073] Optionally, the second acquisition unit includes:
[0074] The second determining module is used to determine based on Determine the edge weights of the directed historical defect propagation graph;
[0075] in, Let the edge weights from node u to node v in the directed historical defect propagation graph described above be... Let be the severity level coefficient of the i-th defect. denoted as the defect repair cycle, and n as the total number of defects.
[0076] Optionally, the second processing unit includes: a first processing module for performing multi-hop propagation on the weighted directed fusion graph with the change point as the root node; a second processing module for determining the influence strength as the product of the influence value of the upstream node and the attenuation edge weight during each hop propagation: the attenuation edge weight product is the product of the normalized edge weight of the weighted directed fusion graph and the attenuation factor; a third processing module for determining the set of affected modules and the influence weight, wherein nodes greater than or equal to a threshold are included in the set of affected modules; and a fourth processing module for generating multiple test cases and corresponding priorities based on the set of affected modules and the weighted directed fusion graph.
[0077] Optionally, the fourth processing module includes: a processing submodule for using an AI model to process the above-mentioned affected module set and the above-mentioned weighted directed fusion graph to generate multiple above-mentioned test cases and corresponding priorities.
[0078] The test case generation device includes a processor and a memory. The first acquisition unit, the second acquisition unit, the first processing unit, the second processing unit, etc., are all stored as program units in the memory. The processor executes the program units stored in the memory to achieve the corresponding functions. All of the above modules are located in the same processor; or, the above modules are located in different processors in any combination.
[0079] The processor contains a kernel, which retrieves the corresponding program units from memory. One or more kernels can be configured. By adjusting kernel parameters, the problem that existing test case generation schemes only select test cases from the existing test case library and cannot dynamically generate new test logic to cope with complex business changes can be addressed.
[0080] The memory may include non-permanent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM, and the memory includes at least one memory chip.
[0081] This invention provides a computer-readable storage medium including a stored program, wherein, when the program is executed, it controls the device where the computer-readable storage medium is located to execute the test case generation method.
[0082] This invention provides a processor for running a program, wherein the program executes the method for generating test cases.
[0083] This invention provides a device including a processor, a memory, and a program stored in the memory and executable on the processor. When the processor executes the program, it performs at least the following steps: acquiring code commit events, parsing a list of changed files and their granularity, and outputting a structured change event object; using an abstract syntax tree parser to parse the source code of the structured change event object, identify the call relationships between modules, classes, and methods to construct a directed static dependency graph, where nodes represent code units and edges represent call or dependency relationships; acquiring historical defect data, including defect IDs, associated code changes, and repair records; based on the correlation analysis of code changes, inferring the propagation path of defects between modules to construct a directed historical defect propagation graph, and assigning initial weights to the edges in the graph based on defect severity, repair cycle, and propagation frequency; performing graph alignment and node matching on the directed static dependency graph and the directed historical defect propagation graph, and generating a weighted directed fusion graph using a weighted fusion algorithm; and generating multiple test cases and corresponding priorities based on the weighted directed fusion graph. The device in this document can be a server, PC, PAD, mobile phone, etc.
[0084] This application also provides a computer program product, which, when executed on a data processing device, is suitable for executing an initialization program with at least the following method steps: acquiring code commit events, parsing a list of changed files and the granularity of changes, and outputting a structured change event object; and using an abstract syntax tree parser to parse the source code of the structured change event object, identify the call relationships between modules, classes, and methods to construct a directed static dependency graph, wherein nodes represent code units and edges represent call or dependency relationships; acquiring historical defect data, including defect IDs, associated code changes, and repair records; based on the correlation analysis of code changes, inferring the propagation path of defects between modules to construct a directed historical defect propagation graph, and assigning initial weights to the edges in the graph based on defect severity level, repair cycle, and propagation frequency; performing graph alignment and node matching on the directed static dependency graph and the directed historical defect propagation graph, and using a weighted fusion algorithm to generate a weighted directed fusion graph; and generating multiple test cases and corresponding priorities based on the weighted directed fusion graph.
[0085] This application also provides a test case generation system, comprising: one or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include methods for performing any of the above-described methods.
[0086] It is obvious to those skilled in the art that the modules or steps of the present invention described above can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. They can be implemented using computer-executable program code, and thus can be stored in a storage device for execution by a computing device. In some cases, the steps shown or described can be performed in a different order than those described herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the present invention is not limited to any particular combination of hardware and software.
[0087] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0088] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0089] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0090] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0091] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0092] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, like read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.
[0093] Computer-readable media include both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.
[0094] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0095] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0096] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for generating test cases, characterized in that, include: Retrieve code commit events, parse the list of changed files and the granularity of the changes, and output a structured change event object; The abstract syntax tree parser is used to parse the source code of the structured change event object, identify the calling relationships between modules, classes and methods, in order to construct a directed static dependency graph, where nodes represent code units and edges represent calling or dependency relationships. Acquire historical defect data, which includes defect IDs, associated code changes, and repair records; based on the correlation analysis of code changes, infer the propagation path of defects between modules to construct a directed historical defect propagation graph, and assign initial weights to the edges in the graph based on defect severity level, repair cycle, and propagation frequency; The directed static dependency graph and the directed historical defect propagation graph are aligned and matched with nodes, and a weighted fusion algorithm is used to generate a weighted directed fusion graph. Multiple test cases and their corresponding priorities are generated based on the weighted directed fusion graph.
2. The method according to claim 1, characterized in that, A weighted fusion algorithm is used to generate a weighted directed fusion graph, including: according to Determine the edge weights of the weighted directed fusion graph; in, Let the edge weights be those between node u and node v in the weighted directed fusion graph. Let be the edge weight from node u to node v in the directed static dependency graph. Let α be the edge weight from node u to node v in the directed historical defect propagation graph, and let α and β be weight coefficients, with the sum of α and β being 1.
3. The method according to claim 2, characterized in that, After generating a weighted directed fusion graph using a weighted fusion algorithm, the method further includes: according to Determine the edge weights of the normalized weighted directed fusion graph; in, The normalized edge weights from node u to node v in the weighted directed fusion graph are: Let be the minimum value of the edge weights in the weighted directed fusion graph. This represents the maximum value of the edge weights in the weighted directed fusion graph.
4. The method according to claim 1, characterized in that, Constructing a directed historical defect propagation graph includes: according to Determine the edge weights of the directed historical defect propagation graph; in, Let be the edge weight from node u to node v in the directed historical defect propagation graph. Let be the severity level coefficient of the i-th defect. denoted as the defect repair cycle, and n as the total number of defects.
5. The method according to claim 1, characterized in that, Based on the weighted directed fusion graph, multiple test cases and their corresponding priorities are generated, including: Using the change point as the root node, perform multi-hop propagation on the weighted directed fusion graph; During each hop of propagation, the influence intensity is determined as the product of the influence value of the upstream node and the product of the attenuation edge weights: the product of the attenuation edge weights is the product of the normalized edge weights of the weighted directed fusion graph and the attenuation factor. Determine the set of affected modules and their impact weights, wherein nodes that are greater than or equal to a threshold are included in the set of affected modules; Multiple test cases and their corresponding priorities are generated based on the set of affected modules and the weighted directed fusion graph.
6. The method according to claim 5, characterized in that, Based on the affected module set and the weighted directed fusion graph, multiple test cases and their corresponding priorities are generated, including: An AI model is used to process the set of affected modules and the weighted directed fusion graph to generate multiple test cases and their corresponding priorities.
7. A test case generation device, characterized in that, include: The first acquisition unit is used to acquire code commit events, parse the list of changed files and the granularity of changes, and output a structured change event object; The abstract syntax tree parser is used to parse the source code of the structured change event object, identify the calling relationships between modules, classes and methods, in order to construct a directed static dependency graph, where nodes represent code units and edges represent calling or dependency relationships. The second acquisition unit is used to acquire historical defect data, which includes defect ID, associated code changes and repair records; based on the association analysis of code changes, it infers the propagation path of defects between modules to construct a directed historical defect propagation graph, and assigns initial weights to the edges in the graph based on defect severity level, repair cycle and propagation frequency. The first processing unit is used to perform graph alignment and node matching on the directed static dependency graph and the directed historical defect propagation graph, and to generate a weighted directed fusion graph using a weighted fusion algorithm. The second processing unit is used to generate multiple test cases and their corresponding priorities based on the weighted directed fusion graph.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 7.
9. A processor, characterized in that, The processor is used to run a program, wherein the program executes the method according to any one of claims 1 to 7 when it runs.
10. A test case generation system, characterized in that, include: One or more processors, a memory, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the one or more programs comprising methods for performing any one of claims 1 to 7.
