A software test case automatic generation method and system of fusion diffusion model

By constructing a unified model of semantic unit table and state grid, combining coverage hole analysis and improved MIO model, and introducing diffusion model for test trajectory denoising generation, the problems of insufficient coverage and path redundancy in existing technologies are solved, and test cases are generated efficiently and defects are triggered in complex systems.

CN122489442APending Publication Date: 2026-07-31BEIJING BOYANG JUTIAN TECHNOLOGY DEVELOPMENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
BEIJING BOYANG JUTIAN TECHNOLOGY DEVELOPMENT CO LTD
Filing Date
2026-06-30
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Existing technologies for generating software test cases suffer from insufficient coverage, path redundancy, and a lack of explicit modeling of the relationship between the program state space structure and test action transitions, resulting in insufficient effectiveness and relevance of test cases in complex system scenarios.

Method used

A unified modeling system for semantic unit tables, state grids, and transition relationships is constructed. Combining coverage hole analysis and an improved MIO model, a diffusion model is introduced to generate test trajectories for noise reduction. Feedback updates are achieved through a capsule archive pool to improve coverage integrity and defect triggering capability.

Benefits of technology

It significantly improves the structural consistency and execution reachability of test case generation, enhances the coverage completeness and defect triggering capability in complex software system scenarios, and improves the efficiency of automated generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122489442A_ABST
    Figure CN122489442A_ABST
Patent Text Reader

Abstract

This invention discloses an automatic software test case generation method and system based on a fusion diffusion model, relating to the fields of software testing and generative modeling technology. The method includes: Step 1, collecting data from the software under test and generating a software execution semantic unit table; Step 2, constructing an executable state lattice and generating test action transition relationships; Step 3, generating a coverage hole map and a set of test targets to be inverted; Step 4, generating test trajectory capsules and constructing a set of latent variables for the test trajectories; Step 5, inputting the coverage hole inversion diffusion model to generate a denoised representation of the test trajectories; Step 6, inputting an improved MIO model to perform target stripping and state reachability verification, generating a target subset; Step 7, constructing an independent capsule archive pool and determining the targets to be sampled; Step 8, generating a diffusion condition package and outputting executable test cases. This invention achieves automatic generation of software test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of software testing and generative modeling technology, and in particular to a method and system for automatically generating software test cases based on a diffusion model. Background Technology

[0002] As software systems continue to expand in scale and interface interaction complexity continues to increase, the demand for automatic generation of high-coverage test cases in software testing is growing. Existing technologies typically rely on manual design of test cases or the generation of test paths based on random strategies and symbolic execution methods, but in practice, insufficient coverage and path redundancy are common problems.

[0003] Traditional test case generation methods often rely on static code analysis or simple path enumeration mechanisms, which struggle to effectively characterize the state evolution relationships and interface call constraints during program execution. This results in limited test case coverage of complex branch structures and abnormal paths. Furthermore, existing machine learning-based test generation methods typically only utilize historical test data for sequence modeling, lacking explicit modeling of the program's state space structure and test action transition relationships. This makes the generation process insufficiently expressive of execution path constraints, easily leading to test trajectories inconsistent with the real execution environment. In addition, existing methods, when addressing insufficient coverage, often employ heuristic rules or local optimization strategies for supplementary test generation, failing to systematically identify coverage gaps in the program execution space and lacking in-depth modeling of the potential structural relationships between defect reproduction paths and historical test trajectories. This results in insufficient effectiveness and relevance of test cases in complex system scenarios.

[0004] Therefore, how to provide a method and system for automatically generating software test cases based on a fusion diffusion model is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention

[0005] One objective of this invention is to propose an automatic software test case generation method and system that integrates a diffusion model. This invention constructs a unified modeling system of semantic unit table, state grid and transition relationship, and combines coverage hole analysis and improved MIO model to realize test target decomposition and capsule scheduling. It introduces a diffusion model to complete the test trajectory denoising generation, so that test cases are generated under the constraints of state reachability and path consistency, and realizes feedback update through capsule archive pool, thereby improving coverage integrity and defect triggering capability.

[0006] A method for automatically generating software test cases based on a fusion diffusion model according to an embodiment of the present invention includes the following steps:

[0007] Step 1: Collect data from the software under test and generate a software execution semantic unit table;

[0008] Step 2: Construct an executable state grid based on the software execution semantic unit table, and generate test action transition relationships;

[0009] Step 3: Extract coverage void units based on the tested software data, software execution semantic unit table, and test action migration relationship to generate a coverage void map and a set of test targets to be inverted;

[0010] Step 4: Extract historical test cases and defect reproduction test cases from the software under test data, convert the historical test cases and defect reproduction test cases into test trajectory capsules, and generate a set of latent variables for the test trajectory.

[0011] Step 5: Input the test trajectory latent variable set, the test target set to be inverted, and the test action migration relationship into the coverage hole inversion diffusion model to generate a denoised representation of the test trajectory;

[0012] Step 6: Input the set of test targets to be inverted into the improved MIO model. After the target stripping of the coverage hole and the state reachability verification, the target unit of the coverage hole is divided into sampleable targets, state-preceding sub-targets and target-triggered sub-targets.

[0013] Step 7: Establish an independent capsule archive pool based on the sampleable target, the state-preceding sub-target, and the target-triggered sub-target, and determine the current target to be sampled;

[0014] Step 8: Generate a diffusion condition package based on the current target to be sampled, generate executable test cases by combining the denoised representation of the test trajectory, update the independent capsule archive pool and the coverage hole map, and output the target test case set.

[0015] Optionally, step one includes:

[0016] The code structure data and interface structure data of the software under test are obtained during the operation process. The code structure data is divided into syntax units to generate method entry units, branch control units, loop control units, exception declaration units and resource operation units.

[0017] Perform field parsing and call relationship mapping on the interface structure data to generate interface entry unit, request parameter unit, response field unit and status return unit;

[0018] Align the method entry unit, interface entry unit, and call relationship in chronological order to construct an execution sequence mapping relationship;

[0019] Perform path aggregation processing on the execution sequence mapping relationship to generate a set of path fragments;

[0020] The path segment set is semantically normalized to generate a software execution semantic unit table.

[0021] Optionally, step two includes:

[0022] The method entry unit and interface entry unit in the software execution semantic unit table are uniformly identified and mapped to generate a set of state nodes;

[0023] Based on the branch control unit, loop control unit, and exception declaration unit, construct the state transition constraint relationship and generate the action edge set;

[0024] The set of state nodes and the set of action edges are structurally associated to generate an initial executable state grid.

[0025] The initial executable state grid is completed based on resource operation statements and assertion statements to generate an enhanced state grid.

[0026] Based on the enhanced state grid, the action dependency paths between state nodes are calculated, and the test action migration relationships are generated.

[0027] Optionally, step three includes:

[0028] The execution sequence in the software under test data is path-segmented to generate a set of basic execution path units;

[0029] Based on the software execution semantic unit table, semantic constraints are labeled on the basic execution path unit set to generate a semantic path constraint set.

[0030] Based on the test action migration relationship, the semantic path constraint set is filtered for state reachability to generate a set of reachable path units.

[0031] A coverage integrity comparison analysis is performed on the set of reachable path units to determine the missing path areas and the untriggered path areas;

[0032] Based on the missing path region and the untriggered path region, a covering hole unit is constructed, and a covering hole map is generated by mapping.

[0033] A set of test targets to be inverted is generated based on the entry node, path constraints, and state transition constraints corresponding to the covered void unit.

[0034] Optionally, step four includes:

[0035] The test case sequence and defect reproduction test case sequence are parsed from the data of the software under test, and the test entry identifier, call order identifier, parameter input set and assertion identifier are extracted.

[0036] The historical test case sequence and the defect reproduction test case sequence are split into action-level segments to generate a set of test action fragments, which include interface request fragments, function call fragments and state initialization fragments.

[0037] The set of test action segments is sequentially aligned with the call order identifier to construct a chain structure of test trajectories;

[0038] Based on the chain structure of the test trajectory, extract the state preconditions, parameter constraints, and assertion dependencies to generate a test trajectory capsule.

[0039] The test trajectory capsule is vectorized and mapped to generate a set of latent variables for the test trajectory.

[0040] Optionally, step five includes:

[0041] The latent variable set of the test trajectory is subjected to noise perturbation to generate a multi-scale noise trajectory representation, and a hierarchical sequence of noise intensity is constructed.

[0042] The set of test targets to be inverted is expanded with target features to generate target entry feature vector, path constraint feature vector and state transition feature vector, and a target guidance feature matrix is ​​constructed.

[0043] The test action transition relationship is converted into a state reachability constraint matrix, and the path consistency of the state reachability constraint matrix is ​​calibrated to generate an executable constraint structure.

[0044] The multi-scale noise trajectory representation, target guidance feature matrix, and executable constraint structure are input into the coverage hole inversion diffusion model, which includes a state constraint denoising unit, a path alignment denoising unit, a parameter boundary correction unit, an assertion consistency generation unit, and a cleanup and completion unit.

[0045] The state constraint denoising unit performs stepwise constraint correction on the noise trajectory based on the state reachability constraint matrix to generate an intermediate state reachability trajectory.

[0046] The path alignment and denoising unit adjusts the path convergence of the state-reachable intermediate trajectory based on the target entry feature vector and the path constraint feature vector to generate a path-consistent intermediate trajectory.

[0047] The parameter boundary correction unit performs boundary correction on the path-consistent intermediate trajectory based on parameter value range constraints, and generates a parameter-consistent trajectory.

[0048] The assertion consistency generation unit generates an assertion verification structure based on the characteristics of the returned fields and the characteristics of the exception triggering, and embeds the parameter consistency trajectory.

[0049] The cleanup and completion unit generates a resource release structure based on the resource operation sequence, completes the assertion verification structure, and outputs a denoised representation of the test trajectory.

[0050] Optionally, step six includes:

[0051] The set of test targets to be inverted is input into the improved MIO model, and the target structure scheduling is performed based on the test action transition relationship and the executable state grid.

[0052] The improved MIO model includes a target reachability decomposition unit, a path consistency constraint unit, a capsule structure construction unit, and a target coupling selection unit;

[0053] The target reachability decomposition unit constructs a state reachability matrix based on the state nodes and action edges in the executable state grid, converts the migration relationship between the state nodes and action edges into an adjacency weight representation, performs path search calculation on the weighted graph structure corresponding to the state reachability matrix, and generates three types of path structures: entry reachable path chain, state precondition path chain, and target trigger path chain. The path weight is accumulated and calculated based on the action migration frequency and state transition stability.

[0054] The path consistency constraint unit constructs a path consistency matrix based on the test action migration relationship, performs path consistency calculation on the entry reachable path chain, the state preceding path chain and the target trigger path chain. The path consistency calculation includes summing the state difference values ​​between adjacent path nodes, and performing shortest path repair compensation calculation on the path break position based on the state reachable matrix to generate a path consistency structure unit.

[0055] The capsule structure construction unit converts the entry segment, state pre-processing segment, and target triggering segment in the path-consistent structure unit into segmented capsule vectors based on the mapping relationship between path nodes and state nodes, forming a target segmented capsule set and constructing an independent capsule file pool.

[0056] The target coupling selection unit constructs a target coupling matrix based on the target segment capsule set. The target coupling matrix is ​​weighted according to path overlap, state blocking relationship and capsule consistency deviation, and prioritizes different coverage hole target units to generate sampleable targets, state-preceding sub-targets and target-triggered sub-targets.

[0057] Optionally, step seven includes:

[0058] The sampleable target, the state-preceding sub-target, and the target-triggered sub-target are subjected to unified structural encoding to generate a target segment index sequence;

[0059] An independent capsule archive pool is constructed based on the target segmented index sequence, and sampleable target capsule area, state-preceding sub-target capsule area and target-triggered sub-target capsule area are established respectively;

[0060] Record the coverage growth results, execution failure results, anomaly trigger results, defect reproduction results, and duplicate coverage results for each capsule area in the independent capsule archive pool to generate a target evolution state record;

[0061] Based on the target evolution state record, calculate the target stability score and the target triggering intensity score, and construct the target priority sequence;

[0062] The target to be sampled is selected according to the target priority sequence, and the corresponding target segment capsule structure is output.

[0063] Optionally, step eight includes:

[0064] The current target to be sampled is encoded with entry node, state constraint and path constraint to generate target guidance condition vector;

[0065] The target guidance condition vector and the denoised representation of the test trajectory are dimensionally aligned and fused to generate a conditionally constrained trajectory representation.

[0066] Based on the conditional constraint trajectory representation, sequence reconstruction calculation is performed to generate candidate test trajectory sequences. The sequence reconstruction calculation is performed in accordance with state transition continuity constraints and path constraint consistency constraints.

[0067] The candidate test trajectory sequence is converted into a test input sequence and an assertion verification sequence to generate an executable test case set.

[0068] The execution results of the executable test case set are recorded, the independent capsule archive pool and the coverage hole map are updated based on the execution results, and the target test case set is output.

[0069] An automatic software test case generation system based on a fusion diffusion model according to an embodiment of the present invention includes:

[0070] The data acquisition and parsing module is used to collect data from the software under test and generate a software execution semantic unit table.

[0071] The state grid construction module is used to construct an executable state grid based on the software execution semantic unit table and generate test action transition relationships.

[0072] The coverage void analysis module is used to extract coverage void units and generate a coverage void map and a set of test targets to be inverted based on the tested software data, the software execution semantic unit table and the test action migration relationship.

[0073] The trajectory capsule building module is used to convert historical test cases and defect reproduction cases into test trajectory capsules and generate a set of latent variables for test trajectories;

[0074] The diffusion trajectory generation module is used to input the test trajectory latent variable set, the test target set to be inverted, and the test action migration relationship into the covering hole inversion diffusion model to generate a denoised representation of the test trajectory;

[0075] The MIO scheduling module is used to perform structured decomposition and screening of the set of test targets to be inverted, and generate sampleable targets, state-preceding sub-targets and target-triggered sub-targets.

[0076] The capsule management module is used to encapsulate and store the targets and generate an independent capsule file pool, and to determine the current target to be sampled;

[0077] The test generation and feedback module is used to generate a diffusion condition package based on the current target to be sampled, generate executable test cases by combining the test trajectory denoising representation, update the independent capsule file pool and the coverage hole map according to the execution results, and output the target test case set.

[0078] The beneficial effects of this invention are:

[0079] This invention constructs a unified structural modeling system that integrates a software execution semantic unit table, executable state grids, and test action transition relationships. It combines a coverage hole analysis module to structurally locate missing path regions in the program execution space and introduces an improved MIO model to decompose and capsule-represent coverage hole targets, achieving hierarchical scheduling and structural constraint control of test targets. Furthermore, a coverage hole inversion diffusion model is used to jointly denoise and generate test trajectory latent variables and target constraints, enabling the test trajectory to converge layer by layer under state reachability constraints, path consistency constraints, and parameter boundary constraints. This significantly improves the structural consistency and execution reachability of test case generation. Simultaneously, a capsule archive pool continuously accumulates and updates historical coverage growth, anomaly triggering, and defect reproduction results, giving the test target selection process dynamic evolution capabilities. This improves the coverage completeness, defect triggering capability, and automated generation efficiency of test cases in complex software system scenarios. Attached Figure Description

[0080] The accompanying drawings are provided to further illustrate the invention and form part of the specification. They are used in conjunction with embodiments of the invention to explain the invention and do not constitute a limitation thereof. In the drawings:

[0081] Figure 1 This is a schematic diagram of a method for automatically generating software test cases based on a fusion diffusion model proposed in this invention;

[0082] Figure 2 This is a schematic diagram of the improved MIO model structure in the automatic generation method of software test cases based on the fusion diffusion model proposed in this invention. Detailed Implementation

[0083] The present invention will now be described in further detail with reference to the accompanying drawings. These drawings are simplified schematic diagrams, illustrating only the basic structure of the invention, and therefore only show the components relevant to the invention.

[0084] refer to Figures 1-2 A method for automatically generating software test cases using a fusion diffusion model includes the following steps:

[0085] Step 1: Collect data from the software under test and generate a software execution semantic unit table;

[0086] Step 2: Construct an executable state grid based on the software execution semantic unit table and generate test action transition relationships;

[0087] Step 3: Extract coverage void units based on the software data under test, the software execution semantic unit table, and the test action migration relationship, and generate a coverage void map and a set of test targets to be inverted;

[0088] Step 4: Extract historical test cases and defect reproduction test cases from the software under test data, convert the historical test cases and defect reproduction test cases into test trajectory capsules, and generate a set of latent variables for the test trajectory.

[0089] Step 5: Input the latent variable set of the test trajectory, the set of test targets to be inverted, and the migration relationship of test actions into the coverage hole inversion diffusion model to generate a denoised representation of the test trajectory;

[0090] Step 6: Input the set of targets to be inverted into the improved MIO model. After the target stripping of the coverage hole and the state reachability verification, the target unit of the coverage hole is divided into sampleable targets, state-preceding sub-targets and target-triggered sub-targets.

[0091] Step 7: Establish an independent capsule archive pool based on the sampleable target, the state-preceding sub-target, and the target-triggered sub-target, and determine the current target to be sampled;

[0092] Step 8: Generate a diffusion condition package based on the current target to be sampled, combine it with the denoised representation of the test trajectory to generate executable test cases, update the independent capsule archive pool and the coverage hole map, and output the target test case set.

[0093] In this embodiment, step one includes:

[0094] The code structure data and interface structure data of the software under test are obtained during the operation process. The code structure data is divided into syntax units to generate method entry units, branch control units, loop control units, exception declaration units and resource operation units.

[0095] Perform field parsing and call relationship mapping on the interface structure data to generate interface entry unit, request parameter unit, response field unit and status return unit;

[0096] Align the method entry unit, interface entry unit, and call relationship in chronological order to construct an execution sequence mapping relationship;

[0097] Perform path aggregation processing on the execution sequence mapping relationship to generate a set of path fragments;

[0098] The path segment set is semantically normalized to generate a software execution semantic unit table.

[0099] In this implementation, step one involves performing unified syntax parsing and field alignment on code structure data and interface structure data. This ensures that the method entry unit, interface entry unit, and execution sequence mapping relationship are associated and constructed within the same semantic space. Furthermore, a continuous splicing relationship of path fragment sets is formed based on the structured identifiers of branch control unit and loop control unit. Semantic units from different sources are then subjected to consistency normalization processing to maintain a structural correspondence between the execution sequence mapping relationship and the path fragment set. This provides a stable structural input foundation for subsequent state grid construction and test action migration relationship generation.

[0100] In this embodiment, step two includes:

[0101] A unified identifier mapping is performed on the method entry unit and interface entry unit in the software execution semantic unit table to generate a set of state nodes;

[0102] Based on the branch control unit, loop control unit, and exception declaration unit, construct the state transition constraint relationship and generate the action edge set;

[0103] The set of state nodes and the set of action edges are structurally associated to generate an initial executable state grid.

[0104] The initial executable state grid is completed based on resource operation statements and assertion statements to generate an enhanced state grid.

[0105] Based on the enhanced state lattice, the action dependency paths between state nodes are calculated, and the test action migration relationships are generated.

[0106] In this implementation, by uniformly identifying and mapping the method entry unit and the interface entry unit, semantic units from different sources are aligned consistently within the same state node space. An action edge set is formed based on the state transition constraint relationship constructed by the branch control unit and the loop control unit. Furthermore, in the process of associating state nodes with action edges, a path-level dependency propagation mechanism is introduced, so that the state changes corresponding to resource operation statements and the verification nodes corresponding to assertion statements form a closed-loop connection relationship within the state grid. This enables the test action transition relationship to reflect the continuity and reachability constraints of state evolution in the execution sequence.

[0107] In this embodiment, step three includes:

[0108] The execution sequence in the software under test data is path-segmented to generate a set of basic execution path units;

[0109] Based on the software execution semantic unit table, semantic constraints are annotated on the basic execution path unit set to generate a semantic path constraint set;

[0110] Based on the test action transition relationship, the semantic path constraint set is filtered for state reachability to generate a set of reachable path units;

[0111] Perform a coverage integrity comparison analysis on the reachable path unit set to determine the missing path areas and untriggered path areas;

[0112] Based on the missing path region and the untriggered path region, a covering hole unit is constructed and mapped to generate a covering hole map;

[0113] A set of test targets to be inverted is generated based on the entry node, path constraints, and state transition constraints corresponding to the covered void unit.

[0114] In this implementation, by performing hierarchical segmentation and semantic constraint mapping on the execution path units in the software under test data, a consistent path alignment structure is formed between the method entry point and the interface entry point of the path segment set. In conjunction with the test action transition relationship, the path segments are subjected to reachability screening and state constraint projection processing, thereby constructing a coverage integrity evaluation benchmark at the path level. Furthermore, based on the path missing area and the untriggered path area, difference aggregation calculation is performed to form a corresponding mapping relationship between the coverage hole unit and the state transition constraint. On this basis, a set of test targets to be inverted with consistent entry constraints, path constraints and state constraints is generated.

[0115] In this embodiment, step four includes:

[0116] The test data is analyzed to extract historical test case sequences and defect reproduction test case sequences, and test entry identifiers, call order identifiers, parameter input sets and assertion identifiers are extracted.

[0117] The historical test case sequence and the defect reproduction test case sequence are split into action-level segments to generate a set of test action fragments, which include interface request fragments, function call fragments and state initialization fragments.

[0118] Align the set of test action fragments with the call sequence identifiers to construct a chain-like structure of test trajectories;

[0119] Based on the chain structure of the test trajectory, the state preconditions, parameter constraints and assertions are extracted to generate test trajectory capsules.

[0120] The test trajectory capsule is vectorized and mapped to generate a set of latent variables for the test trajectory.

[0121] In this implementation, a unified structural analysis is performed on the historical test case sequence and the defect reproduction test case sequence to ensure that the test entry identifier, call sequence identifier, and parameter input set are continuously aligned in the time dimension. A test trajectory chain structure is constructed based on the action-level decomposition results. Furthermore, a joint association mechanism of state preconditions and parameter constraints is introduced into the test trajectory chain structure to enable assertion dependencies to be mapped synchronously with the execution state change process. This ensures that the test trajectory capsule satisfies both call sequence consistency and state transition coherence in its structural expression and provides a stable structural foundation for subsequent latent variable mapping.

[0122] In this embodiment, step five includes:

[0123] The latent variable set of the test trajectory is subjected to noise perturbation to generate a multi-scale noise trajectory representation, and a hierarchical sequence of noise intensity is constructed.

[0124] The set of test targets to be inverted is expanded with target features to generate target entry feature vector, path constraint feature vector and state transition feature vector, and a target guidance feature matrix is ​​constructed.

[0125] The test action transition relationship is converted into a state reachability constraint matrix, and the path consistency of the state reachability constraint matrix is ​​calibrated to generate an executable constraint structure.

[0126] The multi-scale noise trajectory representation, target guidance feature matrix, and executable constraint structure are input into the covering hole inversion diffusion model. The covering hole inversion diffusion model includes a state constraint denoising unit, a path alignment denoising unit, a parameter boundary correction unit, an assertion consistency generation unit, and a cleanup and completion unit.

[0127] The state-constraint denoising unit performs stepwise constraint correction on the noise trajectory based on the state reachability constraint matrix, generating an intermediate state reachability trajectory.

[0128] The path alignment and denoising unit adjusts the path convergence of the reachable intermediate trajectory based on the target entry feature vector and the path constraint feature vector, and generates a path-consistent intermediate trajectory.

[0129] The parameter boundary correction unit performs boundary correction on the path-consistent intermediate trajectory based on the parameter value range constraint, and generates a parameter-consistent trajectory.

[0130] The assertion consistency generation unit generates an assertion verification structure based on the characteristics of the returned fields and the characteristics of the exception triggering, and embeds the parameter consistency trajectory.

[0131] The cleanup and completion unit generates a resource release structure based on the resource operation sequence, completes the assertion verification structure, and outputs a denoised representation of the test trajectory.

[0132] In this implementation, multi-scale noise perturbation modeling is performed on the latent variable set of the test trajectory to express the trajectory states of different granularities in a unified noise space. The entry constraints, path constraints, and state transition constraints in the set of test targets to be inverted are synchronously mapped to the target guidance feature matrix to achieve the layer-by-layer injection of constraint information during the denoising process. Furthermore, under the action of the state reachability constraint matrix, a consistency correction mechanism is formed between the test action transition relationship and the trajectory state evolution process. Through the combined action of path alignment and parameter boundary correction, the generated trajectory maintains a consistent constraint relationship between the structure layer, path layer, and parameter layer, thereby obtaining a denoised representation of the test trajectory that satisfies state reachability and target convergence.

[0133] In this embodiment, step six includes:

[0134] The set of test targets to be inverted is input into the improved MIO model, and the target structure scheduling is performed based on the test action transition relationship and the executable state grid.

[0135] The improved MIO model includes a goal reachability decomposition unit, a path consistency constraint unit, a capsule structure construction unit, and a goal coupling selection unit;

[0136] The target reachability decomposition unit constructs a state reachability matrix based on the state nodes and action edges in the executable state grid, converts the migration relationship between the state nodes and action edges into an adjacency weight representation, performs path search calculation on the weighted graph structure corresponding to the state reachability matrix, and generates three types of path structures: entry reachable path chain, state precondition path chain, and target trigger path chain. The path weight is accumulated based on the frequency of action migration and the stability of state transition.

[0137] The path consistency constraint unit constructs a path consistency matrix based on the test action transition relationship, performs path consistency calculation on the entry reachable path chain, the state preceding path chain and the target trigger path chain. The path consistency calculation includes summing the state difference values ​​between adjacent path nodes, and performing the shortest path repair compensation calculation on the path break position based on the state reachable matrix to generate a path consistency structure unit.

[0138] Based on the mapping relationship between path nodes and state nodes, the capsule structure building unit converts the entry segment, state pre-processing segment, and target triggering segment in the path-consistent structure unit into segmented capsule vectors, forming a target segmented capsule set, and constructs an independent capsule file pool;

[0139] The target coupling selection unit constructs a target coupling matrix based on the target segment capsule set. The target coupling matrix is ​​weighted according to the path overlap, state blocking relationship and capsule consistency deviation, and prioritizes different coverage hole target units to generate sampleable targets, state-preceding sub-targets and target-triggered sub-targets.

[0140] In this implementation, the improved MIO model achieves target scheduling through a dual-matrix coupling of the state reachability matrix and the path consistency matrix. The state reachability matrix is ​​used to characterize the reachability probability weight distribution between state nodes and action edges, while the path consistency matrix is ​​used to characterize the structural deviation relationship between different path chains. During the target reachability decomposition process, the entry reachability path chain, the state preceding path chain, and the target triggering path chain are segmented and recombined to maintain topological consistency of the three types of path structures within a unified state space. During the capsule structure construction process, the path consistency structural units are mapped into hierarchical capsule vectors according to the alignment relationship between the path node sequence and the state node sequence, enabling the capsule archive pool to simultaneously possess path segment indexing and state transition indexing capabilities. During the target coupling selection process, the competitive relationship between targets with different coverage holes is modeled by jointly weighting the path overlap, state blocking relationship, and capsule consistency deviation, thereby completing the structured sorting and filtering of target priorities.

[0141] Both the improved MIO model and the traditional MIO model are used in the multi-objective optimization scheduling process. By decomposing, evaluating and selecting the multi-objective set, they realize the priority ranking of objectives and the selection of the optimal objective. Both are based on state space representation and objective weight calculation to complete the iterative objective update process. Structurally, both include the basic processing flow of objective decomposition and objective selection.

[0142] The improved MIO model introduces a target reachability decomposition unit, a path consistency constraint unit, a capsule structure construction unit, and a target coupling selection unit in its structure. The target path chain is decomposed and its consistency is repaired based on the state reachability matrix and the path consistency matrix. The path segments and state nodes are expressed hierarchically through capsuleification, which expands the target representation from a scalar weight form to a structured path representation.

[0143] Through the above-mentioned improved structure, the target scheduling process can simultaneously characterize the coupling relationship between state reachability, path consistency and target, thereby improving the structural and constraint expression capabilities of the target selection process, making the division of sampleable targets, state-preceding sub-targets and target-triggered sub-targets more stable, and improving the constraint consistency and execution reachability of the subsequent test trajectory generation process.

[0144] In this embodiment, step seven includes:

[0145] A unified structural encoding is performed on sampleable targets, state-preceding sub-targets, and target-triggered sub-targets to generate a target segmented index sequence;

[0146] An independent capsule archive pool is constructed based on the target segmented index sequence, and sampleable target capsule area, state-preceding sub-target capsule area and target-triggered sub-target capsule area are established respectively;

[0147] Record the coverage growth results, execution failure results, abnormal trigger results, defect reproduction results, and duplicate coverage results for each capsule area in the independent capsule archive pool, and generate a target evolution status record;

[0148] Calculate the target stability score and target trigger intensity score based on the target evolution state record, and construct the target priority sequence;

[0149] Select the current target to be sampled based on the target priority sequence and output the corresponding target segment capsule structure.

[0150] In this implementation, by uniformly encoding sampleable targets, state-preceding sub-targets, and target-triggered sub-targets, different types of targets can form aligned representations within the same target segment index sequence. Based on the target evolution state records, the coverage growth changes, execution failure propagation paths, and anomaly triggering paths of each target in continuous generation cycles are correlated and statistically analyzed, thereby forming a dynamic evolution description oriented towards the target level. Furthermore, in the target priority calculation process, a joint evaluation mechanism based on path structure overlap and state blocking relationships is introduced, enabling the competitive relationship between different targets to be quantitatively expressed within a unified structural space. The target state changes are continuously updated through a capsule archive pool, ensuring that the selection result of the current target to be sampled remains consistent with the path structure evolution state.

[0151] In this embodiment, step eight includes:

[0152] Encode the entry node, state constraint, and path constraint of the current target to be sampled to generate a target guidance condition vector;

[0153] The target guidance condition vector and the denoised representation of the test trajectory are dimensionally aligned and fused to generate a conditionally constrained trajectory representation.

[0154] Sequence reconstruction calculations are performed based on conditionally constrained trajectory representations to generate candidate test trajectory sequences. The sequence reconstruction calculations are executed in accordance with state transition continuity constraints and path constraint consistency constraints.

[0155] The candidate test trajectory sequence is converted into a test input sequence and an assertion verification sequence to generate a set of executable test cases.

[0156] Record the execution results of the executable test case set, update the independent capsule archive pool and coverage hole map based on the execution results, and output the target test case set.

[0157] In this implementation, multi-dimensional target encoding is performed on the current target to be sampled, enabling the entry node features, state constraint features, and path constraint features to be structurally expressed in a unified condition vector space. This condition vector is then aligned and fused with the denoised representation of the test trajectory to form a condition-constrained trajectory representation with both state and path consistency. Furthermore, during the sequence reconstruction process, a joint constraint mechanism based on the continuity of state transitions and the consistency of path structure is introduced, enabling the generation process to converge synchronously at the execution sequence layer and the state change layer. This results in candidate test trajectories that satisfy the consistency of target constraints, path constraints, and state constraints. The independent capsule archive pool and the coverage hole map are dynamically updated through execution feedback to maintain a continuous and consistent mapping relationship between the target structure and the test case generation process.

[0158] A software test case automatic generation system based on a fusion diffusion model includes:

[0159] The data acquisition and parsing module is used to collect data from the software under test and generate a software execution semantic unit table.

[0160] The state grid construction module is used to construct executable state grids based on the software execution semantic unit table and generate test action transition relationships;

[0161] The coverage void analysis module is used to extract coverage void units and generate a coverage void map and a set of test targets to be inverted based on the software under test data, the software execution semantic unit table and the test action migration relationship.

[0162] The trajectory capsule building module is used to convert historical test cases and defect reproduction cases into test trajectory capsules and generate a set of latent variables for test trajectories;

[0163] The diffusion trajectory generation module is used to input the test trajectory latent variable set, the test target set to be inverted, and the test action migration relationship into the overlay hole inversion diffusion model to generate a denoised representation of the test trajectory;

[0164] The MIO scheduling module is used to perform structured decomposition and filtering of the set of inversion test targets, generating sampleable targets, state-preceding sub-targets and target-triggered sub-targets;

[0165] The capsule management module is used to store targets in capsule form and generate an independent capsule file pool, and to determine the current target to be sampled;

[0166] The test generation and feedback module is used to generate diffusion condition packages based on the current target to be sampled, combine test trajectory denoising representation to generate executable test cases, update the independent capsule file pool and coverage hole map according to the execution results, and output the target test case set.

[0167] Example 1: To verify the feasibility of this invention in practice, it was applied to an automated regression testing scenario for a medium-sized internet service platform. This platform contains approximately 1200 interface service modules, executing about 3500 test cases daily. During continuous iteration, the system frequently encountered problems such as uncovered local paths, difficulty in locating historical defects during regression testing, and insufficient testing of complex branch scenarios. In this example, the platform's interface call logs, code structure information, and historical test execution records were first uniformly collected and parsed to construct a software execution semantic unit table. Furthermore, an executable state grid containing call chain relationships and control flow information was generated. Based on this, multiple coverage gaps were identified through state transition relationship and execution path analysis. For example, unreached state nodes existed in key business links such as user authentication, order settlement, and exception retries.

[0168] In the coverage hole identification stage, this invention utilizes test action migration relationships to filter path constraints, extracting a coverage hole map and forming a set of approximately 860 test targets to be inverted. Subsequently, historical test cases and defect reproduction cases are structurally decomposed to generate test trajectory capsules, and a set of latent variables for the test trajectory is formed through latent variable mapping. This process transforms historical execution behaviors from discrete test steps into continuous trajectory representations, thereby providing structured input for subsequent diffusion generation.

[0169] In the diffusion generation stage, the latent variable set of test trajectories, the set of test targets to be inverted, and the test action transition relationships are input into the coverage hole inversion diffusion model. Under the action of mechanisms such as state constraint denoising, path alignment, and assertion consistency generation, a denoised representation of the test trajectory is generated, and candidate test trajectories are further generated. Experimental results show that, compared with traditional test generation methods based on stochastic strategies and symbolic execution, this invention significantly improves path coverage and defect triggering capability under the same test resource conditions. The experimental results are shown in Table 1.

[0170] Table 1. Comparison of Test Results of Different Methods

[0171] Statement coverage (%) 78.4 72.1 93.6 Branch coverage (%) 65.2 60.8 90.3 Path coverage (%) 41.7 38.5 84.9 Number of defects detected (items) 126 109 218 Defect reproduction success rate (%) 62.3 58.7 91.5 Test case redundancy rate (%) 37.6 42.1 18.9 Average generation time (ms / test case) 14.8 9.6 16.3

[0172] As shown in Table 1, this invention demonstrates significant improvements in both coverage and defect detection capabilities, and is also significantly superior to the comparative methods in terms of test case redundancy control. Especially in complex business scenarios, the introduction of state reachability constraints and coverage gap inversion mechanisms enables the generated test cases to more accurately reach execution paths that were historically difficult to cover, thereby significantly improving the completeness and effectiveness of system-level testing.

[0173] Further analysis shows that in order payment and abnormal rollback business scenarios, the test trajectory generated by this invention can reliably reproduce more than 91% of historical defect triggering paths, while traditional methods can only reproduce less than 65%. Meanwhile, through the dynamic update mechanism of the capsule archive pool, the test target selection process has continuous evolution capabilities, improving the hole coverage convergence speed by approximately 2.3 times in three consecutive rounds of iterative testing.

[0174] In summary, this invention achieves a shift from rule-driven to structure-driven test case generation by integrating diffusion models, state-reachable structure modeling, and an improved MIO target scheduling mechanism. It has good feasibility and application value in complex software system testing scenarios.

[0175] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.

Claims

1. A software test case automatic generation method of fusion diffusion model, characterized in that, Includes the following steps: Step 1: Collect data from the software under test and generate a software execution semantic unit table; Step 2: Construct an executable state grid based on the software execution semantic unit table, and generate test action transition relationships; Step 3: Extract coverage void units based on the tested software data, software execution semantic unit table, and test action migration relationship, and generate a coverage void map and a set of test targets to be inverted; Step 4: Extract historical test cases and defect reproduction test cases from the software under test data, convert the historical test cases and defect reproduction test cases into test trajectory capsules, and generate a set of latent variables for the test trajectory. Step 5: Input the test trajectory latent variable set, the test target set to be inverted, and the test action migration relationship into the coverage hole inversion diffusion model to generate a denoised representation of the test trajectory; Step 6: Input the set of test targets to be inverted into the improved MIO model. After the target stripping of the coverage hole and the state reachability verification, the target unit of the coverage hole is divided into sampleable targets, state-preceding sub-targets and target-triggered sub-targets. Step 7: Establish an independent capsule archive pool based on the sampleable target, the state-preceding sub-target, and the target-triggered sub-target, and determine the current target to be sampled; Step 8: Generate a diffusion condition package based on the current target to be sampled, generate executable test cases by combining the denoised representation of the test trajectory, update the independent capsule archive pool and the coverage hole map, and output the target test case set.

2. The method of claim 1, wherein the method is characterized by: Step one includes: The code structure data and interface structure data of the software under test are obtained during the operation process. The code structure data is divided into syntax units to generate method entry units, branch control units, loop control units, exception declaration units and resource operation units. Perform field parsing and call relationship mapping on the interface structure data to generate interface entry unit, request parameter unit, response field unit and status return unit; Align the method entry unit, interface entry unit, and call relationship in chronological order to construct an execution sequence mapping relationship; Perform path aggregation processing on the execution sequence mapping relationship to generate a set of path fragments; The path segment set is semantically normalized to generate a software execution semantic unit table.

3. The method for automatically generating software test cases based on a fusion diffusion model according to claim 1, characterized in that, Step two includes: The method entry unit and interface entry unit in the software execution semantic unit table are uniformly identified and mapped to generate a set of state nodes; Based on the branch control unit, loop control unit, and exception declaration unit, construct the state transition constraint relationship and generate the action edge set; The set of state nodes and the set of action edges are structurally associated to generate an initial executable state grid. The initial executable state grid is completed based on resource operation statements and assertion statements to generate an enhanced state grid. Based on the enhanced state grid, the action dependency paths between state nodes are calculated, and the test action migration relationships are generated.

4. The method for automatically generating software test cases based on a fusion diffusion model according to claim 1, characterized in that, Step three includes: The execution sequence in the software under test data is path-segmented to generate a set of basic execution path units; Based on the software execution semantic unit table, semantic constraints are labeled on the basic execution path unit set to generate a semantic path constraint set. Based on the test action migration relationship, the semantic path constraint set is filtered for state reachability to generate a set of reachable path units. A coverage integrity comparison analysis is performed on the set of reachable path units to determine the missing path areas and the untriggered path areas; Based on the missing path region and the untriggered path region, a covering hole unit is constructed, and a covering hole map is generated by mapping. A set of test targets to be inverted is generated based on the entry node, path constraints, and state transition constraints corresponding to the covered void unit.

5. The method for automatically generating software test cases based on a fusion diffusion model according to claim 1, characterized in that, Step four includes: The test case sequence and defect reproduction test case sequence are parsed from the data of the software under test, and the test entry identifier, call order identifier, parameter input set and assertion identifier are extracted. The historical test case sequence and the defect reproduction test case sequence are split into action-level segments to generate a set of test action fragments, which include interface request fragments, function call fragments and state initialization fragments. The set of test action segments is sequentially aligned with the call order identifier to construct a chain structure of test trajectories; Based on the chain structure of the test trajectory, extract the state preconditions, parameter constraints, and assertion dependencies to generate a test trajectory capsule. The test trajectory capsule is vectorized and mapped to generate a set of latent variables for the test trajectory.

6. The method for automatically generating software test cases based on a fusion diffusion model according to claim 1, characterized in that, Step five includes: The latent variable set of the test trajectory is subjected to noise perturbation to generate a multi-scale noise trajectory representation, and a hierarchical sequence of noise intensity is constructed. The set of test targets to be inverted is expanded with target features to generate target entry feature vector, path constraint feature vector and state transition feature vector, and a target guidance feature matrix is ​​constructed. The test action transition relationship is converted into a state reachability constraint matrix, and the path consistency of the state reachability constraint matrix is ​​calibrated to generate an executable constraint structure. The multi-scale noise trajectory representation, target guidance feature matrix, and executable constraint structure are input into the coverage hole inversion diffusion model, which includes a state constraint denoising unit, a path alignment denoising unit, a parameter boundary correction unit, an assertion consistency generation unit, and a cleanup and completion unit. The state constraint denoising unit performs stepwise constraint correction on the noise trajectory based on the state reachability constraint matrix to generate an intermediate state reachability trajectory. The path alignment and denoising unit adjusts the path convergence of the state-reachable intermediate trajectory based on the target entry feature vector and the path constraint feature vector to generate a path-consistent intermediate trajectory. The parameter boundary correction unit performs boundary correction on the path-consistent intermediate trajectory based on parameter value range constraints, and generates a parameter-consistent trajectory. The assertion consistency generation unit generates an assertion verification structure based on the characteristics of the returned fields and the characteristics of the exception triggering, and embeds the parameter consistency trajectory. The cleanup and completion unit generates a resource release structure based on the resource operation sequence, completes the assertion verification structure, and outputs a denoised representation of the test trajectory.

7. The method for automatically generating software test cases based on a fusion diffusion model according to claim 1, characterized in that, Step six includes: The set of test targets to be inverted is input into the improved MIO model, and the target structure scheduling is performed based on the test action transition relationship and the executable state grid. The improved MIO model includes a target reachability decomposition unit, a path consistency constraint unit, a capsule structure construction unit, and a target coupling selection unit; The target reachability decomposition unit constructs a state reachability matrix based on the state nodes and action edges in the executable state grid, converts the migration relationship between the state nodes and action edges into an adjacency weight representation, performs path search calculation on the weighted graph structure corresponding to the state reachability matrix, and generates three types of path structures: entry reachable path chain, state precondition path chain, and target trigger path chain. The path weight is accumulated and calculated based on the action migration frequency and state transition stability. The path consistency constraint unit constructs a path consistency matrix based on the test action migration relationship, performs path consistency calculation on the entry reachable path chain, the state preceding path chain and the target trigger path chain. The path consistency calculation includes summing the state difference values ​​between adjacent path nodes, and performing shortest path repair compensation calculation on the path break position based on the state reachable matrix to generate a path consistency structure unit. The capsule structure construction unit converts the entry segment, state pre-processing segment, and target triggering segment in the path-consistent structure unit into segmented capsule vectors based on the mapping relationship between path nodes and state nodes, forming a target segmented capsule set and constructing an independent capsule file pool. The target coupling selection unit constructs a target coupling matrix based on the target segment capsule set. The target coupling matrix is ​​weighted according to path overlap, state blocking relationship and capsule consistency deviation, and prioritizes different coverage hole target units to generate sampleable targets, state-preceding sub-targets and target-triggered sub-targets.

8. The method for automatically generating software test cases based on a fusion diffusion model according to claim 1, characterized in that, Step seven includes: The sampleable target, the state-preceding sub-target, and the target-triggered sub-target are subjected to unified structural encoding to generate a target segment index sequence; An independent capsule archive pool is constructed based on the target segmented index sequence, and sampleable target capsule area, state-preceding sub-target capsule area and target-triggered sub-target capsule area are established respectively; Record the coverage growth results, execution failure results, anomaly trigger results, defect reproduction results, and duplicate coverage results for each capsule area in the independent capsule archive pool to generate a target evolution state record; Based on the target evolution state record, calculate the target stability score and the target triggering intensity score, and construct the target priority sequence; The target to be sampled is selected according to the target priority sequence, and the corresponding target segment capsule structure is output.

9. The method for automatically generating software test cases based on a fusion diffusion model according to claim 1, characterized in that, Step eight includes: The current target to be sampled is encoded with entry node, state constraint and path constraint to generate target guidance condition vector; The target guidance condition vector and the denoised representation of the test trajectory are dimensionally aligned and fused to generate a conditionally constrained trajectory representation. Based on the conditional constraint trajectory representation, sequence reconstruction calculation is performed to generate candidate test trajectory sequences. The sequence reconstruction calculation is performed in accordance with state transition continuity constraints and path constraint consistency constraints. The candidate test trajectory sequence is converted into a test input sequence and an assertion verification sequence to generate an executable test case set. The execution results of the executable test case set are recorded, the independent capsule archive pool and the coverage hole map are updated based on the execution results, and the target test case set is output.

10. A system for automatically generating software test cases for a fusion-diffusion model, comprising executing the method for automatically generating software test cases for a fusion-diffusion model as described in any one of claims 1 to 9, characterized in that, include: The data acquisition and parsing module is used to collect data from the software under test and generate a software execution semantic unit table. The state grid construction module is used to construct an executable state grid based on the software execution semantic unit table and generate test action transition relationships. The coverage void analysis module is used to extract coverage void units and generate a coverage void map and a set of test targets to be inverted based on the tested software data, the software execution semantic unit table and the test action migration relationship. The trajectory capsule building module is used to convert historical test cases and defect reproduction cases into test trajectory capsules and generate a set of latent variables for test trajectories; The diffusion trajectory generation module is used to input the test trajectory latent variable set, the test target set to be inverted, and the test action migration relationship into the covering hole inversion diffusion model to generate a denoised representation of the test trajectory; The MIO scheduling module is used to perform structured decomposition and screening of the set of test targets to be inverted, and generate sampleable targets, state-preceding sub-targets and target-triggered sub-targets. The capsule management module is used to encapsulate and store the targets and generate an independent capsule file pool, and to determine the current target to be sampled; The test generation and feedback module is used to generate a diffusion condition package based on the current target to be sampled, generate executable test cases by combining the test trajectory denoising representation, update the independent capsule file pool and the coverage hole map according to the execution results, and output the target test case set.