Test case generation method and system based on multi-modal machine learning and dynamic optimization
By employing multimodal machine learning and dynamic optimization methods, test cases containing business rules, code execution paths, and defect propagation chain relationships are generated. This solves the problem of fragmented modal information in existing test case generation methods, achieving more efficient test case generation and resource utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-04-16
- Publication Date
- 2026-05-12
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In existing technologies, test case generation methods are based on a single data source and fail to fully explore the inherent relationship between semantic rules, code execution logic and defect propagation patterns, resulting in test cases that are difficult to meet the testing requirements of complex software systems.
We employ multimodal machine learning and dynamic optimization methods to generate a multimodal associated feature space through cross-modal feature association processing. We use a dynamic attention alignment network to calculate the intensity of feature interactions between modalities and perform dynamic weight allocation. We also generate boundary test cases through an adversarial generative network. Finally, we prioritize test cases by combining the semantic dependency relationship of business rules with the association relationship of defect propagation links to generate a set of target test cases.
It achieves adaptive fusion of multi-dimensional information during the test case generation process, improving the effectiveness and comprehensiveness of test cases, better covering extreme inputs and abnormal execution paths, and optimizing the efficiency of test resource utilization.
Smart Images

Figure CN122019398A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of data processing technology, and in particular to a test case generation method and system based on multimodal machine learning and dynamic optimization. Background Technology
[0002] As software systems become increasingly complex, test case generation, a crucial step in ensuring software quality, directly impacts testing efficiency and defect detection capabilities. Current test case generation methods typically rely on a single data source, with some supplementing test cases by incorporating historical defect records. However, these approaches generally suffer from fragmented modal information, failing to fully exploit the inherent connections between semantic rules, code execution logic, and defect propagation patterns. Consequently, the effectiveness of test cases often falls short of meeting the testing requirements of complex software systems. Summary of the Invention
[0003] In view of this, the present invention provides a test case generation method and system based on multimodal machine learning and dynamic optimization. The technical solution of the present invention is implemented as follows: On one hand, embodiments of the present invention provide a test case generation method based on multimodal machine learning and dynamic optimization. The method includes: performing cross-modal feature association processing on requirement semantic text, source code instruction flow, and historical defect event records in a software testing scenario to generate a multimodal association feature space containing business rule semantic dependencies, code execution path dependencies, and defect propagation link associations; inputting the multimodal association feature space into a dynamic attention alignment network, and dynamically assigning weights to the business rule semantic dependencies, code execution path dependencies, and defect propagation link associations through intermodal feature interaction strength calculation to generate a test case with cross-modal constraints. A unified joint representation vector is generated; dual-task collaborative training of test case generation and defect localization prediction is performed on the unified joint representation vector, and the feature extraction weights of the two tasks are adjusted through gradient backpropagation sharing between tasks to generate a test case generation parameter set; the test case generation parameter set is input into the generator of the adversarial generative network, and the feature representation of the boundary test scenario is strengthened through feature adversarial learning with the discriminator to generate a boundary test case set; priority ranking is performed on the boundary test case set, and the test case coverage weight is calculated based on the semantic dependency relationship of business rules and the correlation relationship of defect propagation links to generate a target test case set containing the priority ranking results.
[0004] On the other hand, embodiments of the present invention provide a computer system including a memory and a processor, wherein the memory stores a computer program that can run on the processor, and the processor executes the program to implement the steps in the above-described method.
[0005] This invention performs cross-modal feature association processing on requirement semantic text, source code instruction flow, and historical defect event records in software testing scenarios. This transforms previously isolated multi-source data into a unified feature space encompassing semantic dependencies of business rules, code execution path dependencies, and defect propagation chain relationships. This allows the test case generation process to simultaneously utilize multi-dimensional information from semantic rules, code structure, and defect history. By using a dynamic attention alignment network to calculate the intensity of intermodal feature interactions and dynamically assign weights, adaptive fusion of features from different modalities is achieved, avoiding information loss or redundancy caused by fixed weights. Test case generation and defect localization prediction tasks are trained collaboratively. Feature extraction weights are adjusted through gradient backpropagation between tasks, enabling the two related tasks to mutually promote and optimize each other, improving the quality of test case generation parameters. Finally, adversarial learning is performed using a generative adversarial network (GAN) to enhance feature representation in boundary testing scenarios. The generated boundary test case set can more comprehensively cover special scenarios such as extreme inputs and abnormal execution paths. Based on the semantic dependencies of business rules and the correlation of defect propagation paths, test case coverage weights are calculated and prioritized. This ensures that the generated target test case set prioritizes coverage of important business rules and high-risk defect propagation paths, maximizing testing effectiveness with limited testing resources. The entire methodology achieves end-to-end processing from multimodal data association, dynamic weight allocation, dual-task collaborative optimization to boundary test case generation and priority ranking, significantly improving the effectiveness, comprehensiveness, and efficiency of test case utilization. Attached Figure Description
[0006] Figure 1 This is a schematic diagram illustrating the implementation process of a test case generation method based on multimodal machine learning and dynamic optimization, provided in an embodiment of the present invention.
[0007] Figure 2 This is a schematic diagram of the hardware entity of a computer system provided in an embodiment of the present invention. Detailed Implementation
[0008] This invention provides a test case generation method based on multimodal machine learning and dynamic optimization, which can be executed by a computer system's processor. The computer system can refer to devices with data processing capabilities, such as servers, laptops, and desktop computers.
[0009] Figure 1 A schematic diagram illustrating the implementation flow of a test case generation method based on multimodal machine learning and dynamic optimization provided in this embodiment of the invention includes: Step S100: Perform cross-modal feature association processing on the semantic text of requirements, source code instruction flow and historical defect event records in the software testing scenario to generate a multimodal association feature space containing semantic dependencies of business rules, dependencies of code execution paths and associations of defect propagation links.
[0010] Semantic text of requirements describes software functional requirements in natural language, outlining the business rules and expected functions the software needs to implement, providing business-level guidance for software development and testing. Source code instruction flow is the sequence of instructions formed during software code execution, reflecting the specific implementation logic and execution order of the software. Historical defect event records are a collection of defect-related information discovered during previous testing or use, including defect descriptions, locations, triggering conditions, and impacts. Cross-modal feature correlation processing involves comprehensively analyzing data from these three different modalities to uncover potential relationships between them. Semantic dependency relationships of business rules reflect the semantic connections and dependencies between elements within a business rule; for example, a business operation may depend on the completion of other operations. Code execution path dependencies reflect the sequence and dependencies between different parts of the code during execution; for example, a function call may depend on the return result of another function. Defect propagation chain relationships describe how defects propagate from one location to another in the software system, and the potential scope and modules affected.
[0011] In one implementation, step S100 may specifically include the following steps S110 to S160: Step S110: Perform semantic role labeling and dependency syntax two-layer parsing on the demand semantic text to identify the argument roles of the core predicates and construct a semantic dependency network containing role hierarchy relationships, where the semantic dominance relationship between argument roles is represented by directed edges.
[0012] Semantic role labeling assigns a semantic role to each word in a sentence, such as agent, patient, or instrument, clarifying the semantic function of each word within the sentence. Dependency parsing analyzes the syntactic dependencies between words in a sentence, determining the dominance and subordination relationships between them. The core predicate is the verb in the sentence that expresses the main action or state, while argument roles are semantic components related to the core predicate, forming the semantic structure of the sentence around it.
[0013] When performing semantic role labeling, machine learning-based methods such as Conditional Random Fields (CRF) models can be used. This model treats semantic role labeling as a sequence labeling problem, training itself by learning from a large amount of labeled data. For example, the semantic text needs to be segmented and tagged with parts of speech first, and then these features are input into the CRF model for training and prediction. For dependency parsing, graph-based parsing algorithms, such as the Arc-Eager algorithm, can be used. This algorithm gradually constructs the dependency syntax tree of the sentence through continuous shifting and reduction operations.
[0014] Step S120: Perform a fusion analysis of the function call graph and control flow graph of the source code instruction flow, extract the dependency relationship between function entry parameters and return values, trace the jump logic of conditional branch statements, generate a code execution path network containing the execution order of basic blocks and data dependencies, and label the execution frequency and branch conditions of path nodes.
[0015] Source code instruction flow is the sequence of instructions formed during software code execution. To gain a deeper understanding of the code's execution logic and dependencies, it's necessary to perform a combined analysis of function call graphs and control flow graphs. Function call graphs illustrate the calling relationships between functions in the code, reflecting their hierarchical structure and dependencies. Control flow graphs describe the execution order and jump logic between basic blocks in the code, clearly showing the execution path. The dependency relationship between function input parameters and return values refers to the possibility that a function's input parameter depends on the return value of another function, or that a function's return value might be used as an input parameter by another function. By extracting these dependencies, we can better understand the code's execution flow and data transfer process.
[0016] Step S130: Perform time-series correlation analysis on historical defect event records, extract the correlation between defect reports and code submissions, construct a propagation link map of defect introduction location, triggering conditions and impact scope, and label the propagation probability and the number of affected modules on the link edges.
[0017] Historical defect event logs are collections of defect-related information discovered during previous software testing or use. To better understand the patterns of defect generation and propagation, temporal correlation analysis is necessary. Temporal correlation analysis involves analyzing the chronological order and relationship between defect reports and code commits. This analysis can identify code commits that may introduce defects. A defect report is a document that provides a detailed description of a defect found in the software, including the defect description, its location, and triggering conditions.
[0018] The defect introduction location refers to the specific location in the code where the defect is introduced; the triggering condition refers to the condition that leads to the defect's occurrence; and the scope of impact refers to the code modules and functions that the defect may affect. The propagation path graph is a graph structure where nodes represent the defect introduction location, triggering condition, and scope of impact, and edges represent the propagation relationships between them. The edges are labeled with propagation probability and the number of affected modules. Propagation probability indicates the likelihood of a defect propagating from one node to another, and the number of affected modules indicates the number of code modules that the defect may affect.
[0019] Step S140: Input the semantic dependency network, code execution path network and defect propagation link graph into the cross-modal association engine, calculate the semantic similarity between semantic nodes and code nodes, the path overlap between code nodes and defect nodes, and the description matching degree between semantic nodes and defect nodes, and generate a three-dimensional association strength matrix.
[0020] The cross-modal correlation engine is a system used to process the correlation relationships between data from different modalities. It takes a semantic dependency network, a code execution path network, and a defect propagation path graph as input, and generates a three-dimensional correlation strength matrix through a series of calculations and analyses. The semantic dependency network reflects the relationships and hierarchical structure between various semantic components in the requirement semantic text, the code execution path network shows the execution logic and dependencies of the code, and the defect propagation path graph describes the generation and propagation patterns of defects.
[0021] Semantic similarity between semantic nodes and code nodes refers to the degree of semantic similarity between nodes (argument roles) in the semantic dependency network and nodes (basic blocks) in the code execution path network. Calculating semantic similarity helps identify the correspondence between requirement semantics and code implementation. Path overlap between code nodes and defect nodes refers to the degree of overlap between nodes in the code execution path network and nodes in the defect propagation network (defect introduction location, triggering conditions, etc.) along their execution paths. Calculating path overlap helps identify code paths that may lead to defects. Description matching between semantic nodes and defect nodes refers to the degree of description matching between nodes in the semantic dependency network and nodes in the defect propagation network. Calculating description matching helps identify potential connections between requirement semantics and defects.
[0022] Step S150: Based on the three-dimensional association strength matrix, perform association modeling on the three modal features. Through intra-modal feature clustering and inter-modal feature alignment, construct a heterogeneous feature network containing semantic-code-defect triple association. Network nodes carry modal type labels and association strength attributes.
[0023] When performing intra-modal feature clustering, clustering algorithms such as K-means clustering can be used. This algorithm divides the feature data into different clusters by iteratively updating the cluster centers. For inter-modal feature alignment, methods based on the association strength matrix can be used to determine the correspondence between different modal features based on the values in the three-dimensional association strength matrix. Through intra-modal feature clustering and inter-modal feature alignment, a heterogeneous feature network containing semantic-code-defect triple associations can be constructed.
[0024] Step S160: Use graph neural networks to learn features from heterogeneous feature networks, and fuse multimodal node information through neighborhood aggregation and message passing mechanisms to generate a multimodal association feature space that preserves topological structure and association relationships.
[0025] In one implementation, step S160 may specifically include the following steps S161 to S166: Step S161: Construct a three-layer graph neural network architecture that includes a modality discrimination embedding layer, a neighborhood aggregation layer, and an association enhancement layer. The modality discrimination embedding layer assigns initial embedding vectors to nodes of different modalities, the neighborhood aggregation layer fuses information from neighboring nodes, and the association enhancement layer enhances cross-modal association features.
[0026] The primary function of the modality-discriminating embedding layer is to assign initial embedding vectors to nodes from different modalities. Since nodes in heterogeneous feature networks come from different modalities (semantics, code, defects) and possess different features and semantic information, a modality-discriminating embedding layer is needed to map them into a unified vector space. The neighborhood aggregation layer is responsible for fusing information from neighboring nodes. In heterogeneous feature networks, each node has its neighboring nodes, which may come from different modalities. The neighborhood aggregation layer updates the feature representation of the current node by aggregating the embedding vectors of its neighbors, enabling the node to acquire information from its neighborhood. The association enhancement layer aims to strengthen cross-modal association features. By further processing the features output by the neighborhood aggregation layer, it highlights the associations between nodes from different modalities, allowing for better fusion of multimodal information. When constructing the modality-discriminating embedding layer, different embedding methods can be used to generate initial embedding vectors for nodes from different modalities. For semantically dependent network nodes, pre-trained language models, such as BERT (Bidirectional Encoder Representations from Transformers), can be used to capture semantic information from natural language. For code execution path network nodes, pre-trained code models, such as CodeBERT, can be used. These models are specifically trained on code data and can understand the semantics and structure of the code. For defect propagation path graph nodes, defect text encoding methods can be used, such as word embedding of the defect description text to generate initial defect embedding vectors.
[0027] The neighborhood aggregation layer can employ Graph Convolutional Networks (GCNs) to fuse neighbor node information. GCNs aggregate neighbor node information by performing convolution operations on the adjacency matrix and feature matrix of each node. For example, the updated feature vector of the current node is obtained by multiplying the feature vectors of neighbor nodes by their corresponding weight matrices and then summing the results. The association enhancement layer can use an attention mechanism to enhance cross-modal association features by calculating attention weights between nodes of different modalities.
[0028] Step S162: In the modality-discriminating embedding layer, the initial semantic embedding is generated by a pre-trained language model for semantic dependency network nodes, the initial code embedding is generated by a code pre-trained model for code execution path network nodes, and the initial defect embedding is generated by defect text encoding for defect propagation link graph nodes. The dimensions of the three embedding vectors are kept consistent.
[0029] In the modality-discriminating embedding layer, different methods are used to generate initial embedding vectors for nodes of different modalities. For semantic dependency network nodes, a pre-trained language model is used to generate initial semantic embeddings. Pre-trained language models are models obtained through unsupervised learning on large-scale text data, capable of learning the semantic and syntactic information of natural language. For example, the BERT model, through a bidirectional Transformer architecture, is pre-trained on a large amount of text data, enabling it to generate high-quality word embedding vectors. When using the BERT model, the text corresponding to the semantic dependency network node is input into the BERT model, and after processing by the model, the initial semantic embedding vector of the node is obtained.
[0030] For network nodes in the code execution path, initial code embeddings are generated using a code pre-trained model. A code pre-trained model is a model specifically trained on code data, capable of understanding the semantics and structure of the code. For example, the CodeBERT model combines the characteristics of natural language and code, and is pre-trained on large-scale code datasets to generate accurate code embedding vectors. The code snippets corresponding to the network nodes in the code execution path are input into the CodeBERT model, and after processing by the model, the initial code embedding vectors for the nodes are obtained.
[0031] For each node in the defect propagation path graph, initial defect embeddings are generated using defect text encoding. Defect text encoding is the process of converting defect description text into vector representations. Word embedding methods, such as Word2Vec, can be used to convert words in the defect description text into vectors, and then these word vectors can be combined into a single defect embedding vector using average pooling or other methods.
[0032] Step S163: In the neighborhood aggregation layer, multi-hop neighborhood sampling is performed for each node. During sampling, nodes of the same modality and nodes interacting across modalities are selected first. The aggregation weight of neighboring nodes is calculated through the attention mechanism. The weight is positively correlated with the correlation strength between nodes, and preliminary aggregation features are generated.
[0033] In practical implementation, a graph neural network (GNN) architecture based on attention mechanisms can be used. For example, a dot product attention mechanism can be used when calculating attention weights. First, for each node, its own feature vector is multiplied by the feature vectors of its neighbors to obtain a similarity score. Then, these scores are normalized using a non-linear activation function (such as the softmax function) to obtain the attention weights for each neighbor node. These weights are positively correlated with the strength of the association between nodes; the stronger the association, the larger the corresponding attention weight. Finally, based on the calculated aggregate weights, the feature vectors of the neighbor nodes are weighted and summed to generate preliminary aggregate features. This preliminary aggregate feature integrates information from the node itself and its neighboring nodes, providing a richer feature representation for subsequent association enhancement layers. For example, for a node in a semantic dependency network, through multi-hop neighborhood sampling and attention mechanism calculation, the feature vectors of its neighboring nodes (including semantic nodes of the same modality and code or defect nodes of cross-modality) are weighted and summed to obtain a preliminary aggregate feature containing more semantic and cross-modal information.
[0034] Step S164: In the association enhancement layer, perform intermodal cross-attention calculation on the preliminary aggregated features. Semantic nodes focus on the execution path features of code nodes and the propagation features of defective nodes. Code nodes focus on the argument role features of semantic nodes and the influence range features of defective nodes. Defective nodes focus on the predicate features of semantic nodes and the branch condition features of code nodes, thereby generating association enhancement features.
[0035] When performing cross-modal attention computation, a multi-head attention mechanism can be employed. This mechanism computes multiple attention heads in parallel, each focusing on different aspects of feature information. Specifically, for each modality node, its initial aggregated features are input into multiple attention heads. Each attention head focuses on specific features of other modality nodes by calculating the attention weights between the query, key, and value. For example, for a semantic node, one attention head might focus on the execution path features of a code node, while another might focus on the propagation features of a defect node. Then, the outputs of the multiple attention heads are concatenated and linearly transformed to obtain the final association-enhancing features.
[0036] Step S165: The initial embedding vector is added to the association enhancement feature through residual connection, and after layer normalization, it is input into the next iteration. During the iteration, the neighborhood sampling radius is dynamically adjusted, and the sampling radius is used for the node pairs corresponding to the association strength.
[0037] To avoid information loss and gradient vanishing issues during feature learning, a residual connection approach is used to add the initial embedding vector to the association-enhanced features. In this step, the initial embedding vector generated by the modality-discriminating embedding layer is added to the association-enhanced features generated by the association-enhanced layer. This preserves the original information of the nodes while incorporating enhanced cross-modal association information. The added feature vector needs to undergo layer normalization. Layer normalization is a normalization method that normalizes the feature vector of each sample so that the mean of the feature vector is 0 and the variance is 1. Layer normalization can accelerate the network training process and improve the stability of the model. The feature vector after layer normalization will be used as the input for the next iteration.
[0038] During the iteration process, the neighborhood sampling radius is dynamically adjusted to better adapt to the different association strengths between nodes. The neighborhood sampling radius determines the sampling range during multi-hop neighborhood sampling; the larger the radius, the wider the sampled neighborhood range. Using a sampling radius corresponding to the association strength of node pairs means that for node pairs with high association strength, the sampling radius is appropriately increased to obtain more neighborhood information related to these nodes. The dynamic adjustment of the neighborhood sampling radius can be based on changes in association strength. For example, an association strength threshold can be set; when the association strength of a node pair exceeds this threshold, the sampling radius is increased; when the association strength is below the threshold, the sampling radius is decreased. Simultaneously, the sampling radius adjustment strategy can be gradually adjusted based on the number of iterations and the model's training progress to achieve better training results.
[0039] Step S166: After the iteration is completed, extract the final embedding vectors of all nodes, and reduce the dimensionality of the final embedding vectors by principal component analysis to generate a multimodal association feature space.
[0040] In practice, the covariance matrix of the final embedded vectors is first calculated, reflecting the correlation between eigenvectors. Then, eigenvalue decomposition is performed on the covariance matrix to obtain eigenvalues and eigenvectors. Eigenvalues represent the importance of each principal component, and eigenvectors represent the direction of the principal components. The top k eigenvectors with the largest eigenvalues are selected, and the final embedded vectors are projected onto the low-dimensional space formed by these k eigenvectors, resulting in dimensionality-reduced eigenvectors. After dimensionality reduction through principal component analysis, a multimodal correlation feature space is generated. This space preserves the topology and correlations of the heterogeneous feature network while reducing the dimensionality of the features, making subsequent processing and analysis more efficient.
[0041] Step S200: Input the multimodal associated feature space into the dynamic attention alignment network, and dynamically assign weights to the semantic dependency relationship of business rules, the dependency relationship of code execution path, and the correlation relationship of defect propagation link through the calculation of the feature interaction strength between modalities, so as to generate a unified joint representation vector with cross-modal constraints.
[0042] In one implementation, step S200 may specifically include the following steps S210 to S260: Step S210: Construct a dynamic attention alignment network that includes a modal interaction analysis module, a dynamic weight calculation module, and a feature fusion module. The modal interaction analysis module is used to calculate the feature interaction intensity, the dynamic weight calculation module is used to generate a weight allocation scheme, and the feature fusion module is used to generate a joint representation vector.
[0043] The Dynamic Attention Alignment Network consists of three main modules, each with its specific function. The Modal Interaction Analysis module is responsible for calculating the interaction strength between different modal features. It analyzes data in the multimodal association feature space to uncover the correlations and interactions between different modal features. For example, it can analyze the interactions between semantic consistency, structural similarity, and temporal correlation between semantic dependencies of business rules and code execution path dependencies.
[0044] The dynamic weight calculation module generates a weight allocation scheme based on the interaction strength calculated by the modal interaction analysis module. This module considers the importance and interrelationships of different modal features and dynamically adjusts the weight of each modal relationship. The feature fusion module then fuses the features of different modalities according to the weight allocation scheme generated by the dynamic weight calculation module to generate a joint representation vector. It integrates feature information from different modalities, such as semantic dependencies of business rules, dependencies of code execution paths, and correlations of defect propagation links, into a single vector, forming a unified representation.
[0045] Different neural network architectures can be used when building these modules. For example, the modal interaction analysis module can use a multilayer perceptron (MLP) to calculate the interaction strength, the dynamic weight calculation module can use an optimization algorithm-based network to generate a weight allocation scheme, and the feature fusion module can use fully connected layers to achieve feature fusion.
[0046] Step S220: Input the multimodal association feature space into the modal interaction analysis module, and calculate the interaction strength between the semantic dependency relationship of business rules and the dependency relationship of code execution path, the interaction strength between the dependency relationship of code execution path and the association relationship of defect propagation link, and the interaction strength between the semantic dependency relationship of business rules and the association relationship of defect propagation link. The interaction strength is calculated by combining the feature co-occurrence frequency and the association strength matrix.
[0047] After inputting the multimodal association feature space into the modal interaction analysis module, the interaction strength between different modal relationships is calculated. First, the interaction strength between business rule semantic dependencies and code execution path dependencies is calculated. Business rule semantic dependencies describe the logic and rules at the business level, while code execution path dependencies reflect the specific implementation and execution order of the code; their interaction strength reflects the degree of correspondence between business rules and code implementation. The interaction strength between code execution path dependencies and defect propagation chain relationships reflects the connection between code execution and defect propagation. For example, if a certain code execution path is prone to triggering defect propagation, then their interaction strength will be relatively high. The interaction strength between business rule semantic dependencies and defect propagation chain relationships reflects the potential connection between business rules and defect generation and propagation.
[0048] To calculate the interaction strength, both feature co-occurrence frequency and association strength matrix are considered. Feature co-occurrence frequency refers to the frequency with which different modal features appear simultaneously in the same sample or scenario. For example, if a business rule and a code execution path appear simultaneously in multiple test cases, it indicates a high co-occurrence frequency between them, suggesting a potentially strong interaction relationship. The association strength matrix, generated in the previous steps, reflects the degree of association between different modal nodes.
[0049] In specific calculations, the co-occurrence frequencies of different modal features can be counted separately, and then weighted and summed with the corresponding elements in the association strength matrix. For example, for the interaction strength between semantic dependency of business rules and code execution path dependency, their feature co-occurrence frequencies can be multiplied by a weight, and then the corresponding elements in the association strength matrix can be multiplied by another weight to obtain the final interaction strength.
[0050] Step S230: Construct an interaction intensity tensor based on the interaction intensity between the three modalities, input the interaction intensity tensor into the dynamic weight calculation module, extract the main interaction components through tensor decomposition, and assign initial weights to the modal pairs corresponding to the main interaction components.
[0051] In one implementation, step S230 may specifically include the following steps S231 to S237: Step S231: Construct an interaction intensity evaluation index system, including semantic consistency index, structural similarity index, and temporal correlation index. The semantic consistency index is calculated by cosine similarity, the structural similarity index is calculated by graph edit distance, and the temporal correlation index is calculated by event co-occurrence window analysis.
[0052] In one implementation, step S231 may specifically include the following steps S2311 to S2316: Step S2311: Convert the semantic dependency relationship of business rules and the dependency relationship of code execution path into a semantic vector representation. Calculate the cosine value of the angle between the vectors in the vector space using cosine similarity. The larger the value, the closer the semantic relationship.
[0053] For semantic dependencies in business rules, pre-trained language models such as BERT can be used. The textual description of the business rule is input into the BERT model. After processing, the model obtains semantic vector representations for each word. Then, pooling operations (such as average pooling) combine these word vectors into a single semantic vector, representing the semantic dependency relationship of the business rule. For code execution path dependencies, pre-trained code models such as CodeBERT can be used. The code snippet is input into the CodeBERT model, and similarly processed and pooled, yielding semantic vectors representing the code execution path dependencies. After obtaining these two semantic vectors, cosine similarity is used to calculate the cosine of the angle between them in the vector space. The formula for cosine similarity is the dot product of the two vectors divided by the product of their magnitudes. The value of cosine similarity ranges from -1 to 1. The closer the value is to 1, the closer the directions of the two vectors are, i.e., the stronger the semantic association; the closer the value is to -1, the more opposite the directions of the two vectors are, and the weaker the semantic association; a value close to 0 indicates that there is almost no semantic association between the two vectors.
[0054] Step S2312: Represent the multimodal feature structure as a directed graph, and calculate the number of insertion, deletion and replacement operations required to transform one graph into another using the graph edit distance algorithm. The fewer the number of operations, the more similar the structures are.
[0055] For semantic dependencies in business rules, the semantic dependency network can be viewed as a directed graph, where nodes are argument roles and edges represent semantic dominance relationships. For code execution path dependencies, the code execution path network is a directed graph, where nodes are basic blocks and edges represent execution order and jump relationships. For defect propagation chain relationships, the defect propagation chain graph is also a directed graph, where nodes represent the defect introduction location, triggering conditions, and scope of impact, and edges represent propagation relationships.
[0056] The graph edit distance algorithm is a method used to calculate the similarity between two graphs. It measures the similarity of graphs by calculating the minimum number of insertion, deletion, and replacement operations required to transform one graph into another. An insertion operation adds a new node or edge to one graph, a deletion operation removes a node or edge from one graph, and a replacement operation replaces a node or edge in one graph with a corresponding node or edge in another graph.
[0057] Step S2313: Divide the co-occurrence window based on the event timestamp information, count the co-occurrence frequency of different modal features within the same time window, and use the ratio of the normalized co-occurrence frequency to the time window size as the temporal correlation index.
[0058] To analyze the temporal correlations among semantic dependencies of business rules, code execution path dependencies, and defect propagation chain relationships, co-occurrence windows are defined based on event timestamp information. Event timestamps record the time of occurrence of each event (such as the execution of business rules, code submission, defect discovery, etc.). The co-occurrence window is a time interval within which the co-occurrence of different modalities is statistically analyzed.
[0059] For example, the size of the co-occurrence window can be determined based on factors such as the execution cycle of business rules and the development and testing cycle of code. After dividing the co-occurrence window, the co-occurrence frequency of different modal features within the same time window is counted. Co-occurrence frequency refers to the number of times different modal features appear simultaneously within the same co-occurrence window. For example, if a certain operation of a business rule and a certain step of code execution appear multiple times simultaneously within a certain co-occurrence window, then their co-occurrence frequency is relatively high.
[0060] Normalizing the co-occurrence frequency eliminates differences in frequency across different co-occurrence window sizes and modal features. Finally, the ratio of the normalized co-occurrence frequency to the time window size is used as a temporal correlation index. This index reflects the degree of temporal correlation between different modal features. A larger ratio indicates a stronger temporal correlation between the different modal features, meaning their occurrence is more synchronous. For example, if a certain operation of a business rule and a certain step of code execution have high co-occurrence frequencies across multiple co-occurrence windows, and the time window sizes are appropriate, then their temporal correlation index will be relatively high, indicating a strong temporal correlation between the business rule and code execution.
[0061] Step S2314: Determine the fusion weights of semantic consistency index, structural similarity index, and temporal correlation index through training with historical association data, so as to maximize the correlation between the comprehensive evaluation result and the actual association strength.
[0062] Machine learning methods can be used to train and determine the fusion weights. For example, a linear regression model can be used, with semantic consistency, structural similarity, and temporal correlation indices as input features, and the actual correlation strength as the target output. By training the linear regression model with a large amount of historical correlation data, the model automatically learns the weights of each indicator, minimizing the error between the model's predicted output (i.e., the overall evaluation result) and the actual correlation strength. During training, the least squares method is used to estimate the model's parameters (i.e., the fusion weights). The goal of the least squares method is to minimize the sum of squared errors between the predicted and actual values. By continuously adjusting the fusion weights, the model can better fit the historical correlation data, thus obtaining the optimal fusion weights.
[0063] Step S2315: Automatically adjust the calculation parameters of each index according to the multimodal feature type. Increase the semantic consistency weight for text modal features, increase the structural similarity weight for graphic modal features, and increase the temporal correlation weight for time-series modal features.
[0064] Textual modal features primarily include the semantic text of requirements upon which the semantic dependencies of business rules are based. Since textual data mainly expresses semantic information, the weight of semantic consistency is increased when evaluating the interaction strength of textual modal features. Semantic consistency metrics better reflect the degree of semantic association between texts; by increasing their weight, the interaction strength between textual modal features and other modal features can be evaluated more accurately. For example, when comparing semantic dependencies of business rules and code execution path dependencies, if the business rules are described in textual form, giving higher weight to the semantic consistency metric when calculating interaction strength can better highlight the semantic matching degree between the business rules and the code.
[0065] Graph modal features, such as code execution path networks and defect propagation link graphs, are represented by graph structures. Graph structures focus more on the relationships between nodes and edges, i.e., structural information. Therefore, for graph modal features, increasing the weight of structural similarity is beneficial. The structural similarity index, obtained through the graph edit distance algorithm, effectively measures the degree of similarity between graph structures. Increasing its weight can more accurately assess the structural correlation between graph modal features and other modal features. For example, when comparing code execution path dependencies and defect propagation link correlations, since they are both represented by graph structures, increasing the weight of the structural similarity index can more effectively discover the structural similarities between code execution paths and defect propagation paths.
[0066] Temporal modal features are time-related characteristics, such as code commit time and defect discovery time. These features emphasize temporal correlation and sequence. Therefore, for temporal modal features, increasing the weight of temporal correlation is crucial. Temporal correlation metrics, analyzed through co-occurrence windows, can reflect the temporal synchronicity of different modal features; increasing their weight allows for a more accurate assessment of the temporal correlation between temporal modal features and other modal features. For example, when analyzing code execution path dependencies and defect propagation chain relationships, considering the time factors of code commit and defect discovery, increasing the weight of temporal correlation can better reveal the temporal correlation between code changes and defect occurrence.
[0067] Step S2316: Store the optimal combination of evaluation metrics for different types of multimodal feature pairs, and complete the selection of evaluation metrics through feature type matching.
[0068] In practical applications, when it is necessary to evaluate the interaction strength of a certain type of multimodal feature pair, the selection of evaluation metrics is accomplished through feature type matching. Based on the type of the input multimodal feature pair, the corresponding metric combination is found from the stored optimal metric combinations, and these metrics and weights are used directly to calculate the interaction strength. This avoids the need for complex parameter adjustments and experiments each time, improving evaluation efficiency. Furthermore, since validated optimal metric combinations are used, the accuracy of the evaluation results is guaranteed.
[0069] Step S232: Calculate the scores of the semantic dependency relationship of business rules and the code execution path dependency relationship on the three indicators respectively, and sum them by weight to obtain the first interaction strength.
[0070] Step S233: Calculate the scores of the code execution path dependency relationship and the defect propagation link relationship on three indicators, and sum them by weight to obtain the second interaction strength.
[0071] Step S234: Calculate the scores of the semantic dependency relationship of business rules and the correlation relationship of defect propagation link on three indicators, and sum them by weight to obtain the third interaction strength.
[0072] Step S235: Construct an interaction intensity tensor from the three interaction intensities, input it into the dynamic weight calculation module, extract the main interaction components through tensor decomposition, and assign initial weights to the modal pairs corresponding to the main interaction components.
[0073] The calculated first interaction strength (the interaction strength between the semantic dependency relationship of business rules and the dependency relationship of code execution path), second interaction strength (the interaction strength between the dependency relationship of code execution path and the association relationship of defect propagation path), and third interaction strength (the interaction strength between the semantic dependency relationship of business rules and the association relationship of defect propagation path) are constructed into an interaction strength tensor. The interaction strength tensor can be a three-dimensional tensor, with each dimension corresponding to a modal relationship, and the elements in the tensor are the interaction strengths of the corresponding modal pairs.
[0074] This interaction strength tensor is input into the dynamic weight calculation module, and tensor decomposition techniques are used to extract the main interaction components. Tensor decomposition is the process of decomposing a high-order tensor into multiple low-order tensors. Through decomposition, the main components and structure of the tensor can be found. For example, the CANDECOMP / PARAFAC (CP) decomposition method can be used to decompose the interaction strength tensor into the sum of multiple rank-1 tensors, with each rank-1 tensor corresponding to a main interaction component.
[0075] The modal pairs corresponding to the main interaction components are assigned initial weights. These initial weights reflect the initial importance of different modal relationships when generating a unified joint representation vector. For example, if a main interaction component corresponds to a business rule semantic dependency relationship and a code execution path dependency relationship, then in the initial stage, these two modal relationships will be given relatively high weights in the dynamic weight allocation.
[0076] Step S236: Minimize the deviation between weight allocation and interaction intensity through iterative optimization. The error is measured by mean square error. The weights are adjusted using gradient descent until the error is less than the preset range.
[0077] Gradient descent is used to adjust the weights. For example, first, the gradient of the mean squared error with respect to each weight is calculated; the gradient represents the rate of change of the objective function with respect to the current weight. Then, based on the magnitude and direction of the gradient, the weights are updated according to a certain learning rate. The learning rate controls the step size of each weight update; an excessively large learning rate may lead to overly large weight updates, preventing convergence to the optimal value; an excessively small learning rate will result in too slow convergence.
[0078] In each iteration, the mean squared error (MSE) of the current weight allocation is calculated, and the weights are then updated using gradient descent. This process is repeated until the MSE is less than a preset range. The preset range is a threshold set according to actual needs; when the MSE is less than this threshold, the weight allocation is considered to have reached a relatively ideal state, and the iteration stops.
[0079] Step S237: Multiply the optimized weight allocation result with the modal features in the multimodal association feature space to generate weighted modal features. The value of each dimension of the weighted modal features is the product of the original feature value and the corresponding modal weight.
[0080] For the feature vector of semantic dependencies in business rules, the value of each dimension is multiplied by the corresponding weight of the semantic dependency in the business rule. Similarly, for the feature vectors of code execution path dependencies and defect propagation chain relationships, they are multiplied by their corresponding optimized weights to obtain weighted feature vectors of code execution path dependencies and defect propagation chain relationships. Each dimension of the weighted modal features is the product of the original feature value and the corresponding modality weight. This weighting operation allows different modal features to contribute reasonably according to their importance (reflected by the weights) when generating a unified joint representation vector. For example, if a certain modal relationship has a higher weight, its features will occupy a larger proportion in the unified joint representation vector after weighting, thus highlighting the information of that modal relationship.
[0081] Step S240: Based on the initial weights, the semantic dependency relationship features of business rules, the code execution path dependency relationship features, and the defect propagation link relationship features are weighted to generate weighted modal features. During the weighting process, the weights are dynamically adjusted. When the variance of a certain modal feature deviates from the preset range, its weight is adjusted accordingly.
[0082] After obtaining the initial weights, the semantic dependency features of business rules, the code execution path dependency features, and the defect propagation link association features are weighted according to these weights. For the semantic dependency feature vector of business rules, the values of each dimension are multiplied by the initial weight corresponding to the semantic dependency of business rules; similar weighting operations are also performed on the code execution path dependency feature vector and the defect propagation link association feature vector, respectively, to obtain the initial weighted modal features.
[0083] During the weighting process, the weights are dynamically adjusted. To ensure the stability and rationality of different modal features in the unified joint representation vector, the concept of modal feature variance is introduced. Variance reflects the dispersion of each dimension value in the feature vector. The preset range is a variance threshold set according to the actual situation, used to judge whether the dispersion of the modal features is within a reasonable range. When the variance of a modal feature deviates from the preset range, its weight is adjusted accordingly. If the variance of a modal feature is too large, it indicates that the values of each dimension of the feature vector are significantly different, which may have a significant impact on the generation of the unified joint representation vector. In this case, the weight of the modal feature can be appropriately reduced to minimize its impact. Conversely, if the variance of a modal feature is too small, it indicates that the values of each dimension of the feature vector are relatively concentrated, which may provide limited information. In this case, the weight of the modal feature can be appropriately increased to enhance its contribution to the unified joint representation vector.
[0084] Step S250: Input the weighted modal features into the feature fusion module, perform element-wise multiplication on the weighted semantic features and weighted code features to obtain semantic-code fusion features, and concatenate the semantic-code fusion features with the weighted defect features to generate a preliminary joint representation vector.
[0085] Step S260: Perform cross-modal consistency verification on the preliminary joint representation vector, calculate the distribution similarity of the semantic feature part, code feature part and defect feature part, and when the distribution of a certain part deviates from the overall distribution by more than a preset range, readjust the corresponding modal weights through the dynamic weight calculation module, repeat the fusion process until the consistency constraint is met, and generate a unified joint representation vector.
[0086] Cross-modal consistency verification primarily involves calculating the distribution similarity between the semantic feature component, code feature component, and defect feature component in the preliminary joint representation vector. Distribution similarity can be measured using statistical methods, such as KL divergence. Specifically, the KL divergence between the semantic feature component and the overall distribution, the code feature component and the overall distribution, and the defect feature component and the overall distribution are calculated. The preset range is a threshold set based on actual conditions to determine whether a certain part of the distribution deviates excessively from the overall distribution. When a certain part of the distribution deviates from the overall distribution by more than the preset range, it indicates that the performance of that modal feature in the unified joint representation vector is inconsistent with other modal features, which may affect the quality of the unified joint representation vector.
[0087] At this point, the weights of the corresponding modalities are readjusted through the dynamic weight calculation module. For example, if the distribution of semantic features deviates from the overall distribution by more than a preset range, the weights of the semantic dependencies of the business rules are adjusted. After the weights are readjusted, the feature fusion process is repeated, that is, element-wise multiplication and channel concatenation are performed on the weighted modal features to generate a new preliminary joint representation vector.
[0088] Repeat this process of cross-modal consistency verification, weight adjustment, and feature fusion until the distribution similarity of the semantic feature part, code feature part, and defect feature part all meet the consistency constraint, that is, the difference between the distribution of all parts and the overall distribution is within the preset range. At this point, the generated joint representation vector is the final unified joint representation vector.
[0089] Step S300: Perform dual-task collaborative training of test case generation and defect localization prediction on the unified joint representation vector. Adjust the feature extraction weights of the two tasks through gradient backpropagation sharing between tasks to generate a test case generation parameter set.
[0090] In one implementation, step S300 may specifically include the following steps S310 to S360: Step S310: Construct a dual-task network architecture that includes a shared feature extraction layer, a test case generation task layer, and a defect location prediction task layer. The shared feature extraction layer provides common features for the dual tasks, the test case generation task layer outputs test case parameters, and the defect location prediction task layer outputs the probability of defect location.
[0091] A dual-task network architecture is constructed, consisting of three main parts. The shared feature extraction layer, the foundation of the entire network, receives a unified joint representation vector as input and extracts common features through a series of neural network layers. These common features contain information on business rules, code execution, and defect propagation, providing a common foundation for both test case generation and defect localization / prediction tasks.
[0092] The test case generation task layer receives general features output from the shared feature extraction layer and generates test case parameters using specific models and algorithms. Test case parameters include the sequence of input parameters, the sequence of execution steps, and the sequence of expected results. For example, a sequence generation model can generate test case input parameters and execution steps that conform to business rules and code logic based on general features.
[0093] The defect localization and prediction task layer also receives general features from the shared feature extraction layer and predicts the probability distribution of defects in code modules using a classification model. This classification model can be a fully connected neural network that takes the general features as input and outputs the probability of a defect in each code module. Through this task layer, the location and probability of potential defects in the code can be predicted, providing a basis for defect localization.
[0094] When constructing the shared feature extraction layer, a hybrid structure of convolutional and recurrent layers can be used. Convolutional layers can capture local feature interactions, extracting local patterns and features from the input features. Recurrent layers can model temporal dependencies, making them very effective for handling features with temporal order (such as code execution steps). The test case generation task layer can use sequence generation models, such as Long Short-Term Memory (LSTM) networks or Gated Recurrent Units (GRUs), which can process sequential data and generate logically consistent test case sequences. The defect location prediction task layer can use fully connected neural networks, performing nonlinear transformations on general features through multiple hidden layers to ultimately output the probability of defect location.
[0095] Step S320: Input the unified joint representation vector into the shared feature extraction layer, extract deep features through a hybrid structure of convolutional and recurrent layers. The convolutional layer captures local feature interactions, and the recurrent layer models temporal dependencies to generate a dual-task shared feature vector.
[0096] Step S330: Input the dual-task shared feature vector into the test case generation task layer, generate the input parameter sequence, execution step sequence and expected result sequence of the test cases through the sequence generation model, and calculate the edit distance loss between the generated sequence and the real test case sequence as the test case generation task loss.
[0097] After inputting the shared feature vector from the two tasks into the test case generation task layer, a sequence generation model is used to generate the input parameter sequence, execution step sequence, and expected result sequence of the test cases. The sequence generation model can be based on a recurrent neural network (RNN), such as LSTM or GRU, or it can be based on a Transformer architecture. These models can progressively generate a sequence of test cases that conforms to business rules and code logic based on the input shared feature vector from the two tasks.
[0098] To evaluate the quality of the generated test case sequences, the edit distance loss between the generated sequences and the real test case sequences is calculated. Edit distance refers to the minimum number of insertion, deletion, and replacement operations required to transform one sequence into another. By calculating the edit distance between the generated sequences and the real test case sequences, the degree of difference between them can be measured. The smaller the edit distance, the closer the generated test case sequences are to the real sequences, and the higher the generation quality. The edit distance loss is used as the test case generation task loss. During training, the parameters of the test case generation task layer are optimized by minimizing this loss, enabling the model to generate more accurate and realistic test case sequences. For example, gradient descent can be used to update the weights of the sequence generation model based on the gradient of the edit distance loss, gradually improving the model's generation capability.
[0099] Step S340: Input the shared feature vector of the two tasks into the defect localization prediction task layer, predict the defect probability distribution of the code module through the classification model, calculate the cross-entropy loss between the predicted distribution and the actual defect location, and use it as the defect localization prediction task loss.
[0100] The classification model can be a fully connected neural network that takes a shared feature vector from both tasks as input, undergoes nonlinear transformations through multiple hidden layers, and finally outputs the probability of a defect in each code module. For example, assuming the code is divided into multiple modules, the classification model will output a defect probability value for each module, and these probability values constitute a defect probability distribution. This probability distribution reflects the model's prediction of the likelihood of a defect in each code module.
[0101] To evaluate the accuracy of defect location prediction, the cross-entropy loss between the predicted distribution and the true defect location is calculated. Cross-entropy is a metric that measures the difference between two probability distributions. In classification problems, cross-entropy loss can effectively reflect the degree of difference between the predicted result and the true label. The true defect location can be represented as a probability distribution, where the probability of a module with a true defect is 1, and the probability of other modules is 0.
[0102] The defect localization prediction task loss can be obtained by calculating the cross-entropy loss between the predicted distribution and the actual defect location. During training, the parameters of the defect localization prediction task layer are optimized by minimizing this loss, enabling the classification model to more accurately predict the defect probability distribution of code modules.
[0103] Step S350: The test case generation task loss and the defect location prediction task loss are weighted and summed to generate a joint loss function. The weights are dynamically adjusted according to the performance of the two tasks. If the task accuracy is low, the weight is high, and if the accuracy is high, the weight is low.
[0104] In the initial training phase, the accuracy of the test case generation task may be low, while the accuracy of the defect localization and prediction task may be high. Therefore, in the joint loss function, the weight of the test case generation task loss is increased, while the weight of the defect localization and prediction task loss is decreased. As training progresses, when the accuracy of the test case generation task improves while the accuracy of the defect localization and prediction task decreases, the weights are adjusted accordingly, increasing the weight of the defect localization and prediction task loss and decreasing the weight of the test case generation task loss.
[0105] Step S360: Perform backpropagation based on the joint loss function, calculate the gradient of the loss with respect to the parameters of the shared feature extraction layer. This gradient is the weighted sum of the gradient of the test case generation task and the gradient of the defect localization prediction task. The weights are consistent with the dynamic weights of the two tasks. Update the parameters of the shared feature extraction layer using the gradient descent method, and adjust the feature extraction weights of the two tasks synchronously. Iterate training until the joint loss converges, and extract the network parameters of the test case generation task layer as the test case generation parameter set.
[0106] In one implementation, step S360 may specifically include the following steps S361 to S367: Step S361: In each backpropagation process, calculate the gradient of the test case generation task loss with respect to each parameter of the shared feature extraction layer, and denot it as the first gradient.
[0107] For example, suppose there is a convolutional layer in the shared feature extraction layer, whose parameters include the weights and biases of the convolutional kernel. During backpropagation, the partial derivatives of the test case generation task loss with respect to the kernel weights and biases are calculated to obtain the corresponding gradient values. Similarly, for the recurrent layers in the shared feature extraction layer, the gradient of the loss with respect to its parameters (such as the weight matrix and bias vector) is also calculated. The first gradient reflects the trend of the test case generation task loss changing with the parameters under the current parameters. Based on this gradient, the parameters can be adjusted to gradually reduce the test case generation task loss.
[0108] Step S362: Calculate the gradient of the defect localization prediction task loss with respect to each parameter of the shared feature extraction layer, denoted as the second gradient.
[0109] Using the backpropagation algorithm, starting from the defect localization and prediction task layer, the partial derivatives of the loss with respect to the parameters of the shared feature extraction layer are calculated progressively backward. For the convolutional and recurrent layers in the shared feature extraction layer, the gradient of the loss with respect to its parameters is calculated. For example, the partial derivatives of the defect localization and prediction task loss with respect to the convolutional kernel weights and biases of the convolutional layers, and the weight matrix and bias vector of the recurrent layers, are calculated. The second gradient reflects the rate of change of the defect localization and prediction task loss with respect to the parameters of the shared feature extraction layer. Understanding this gradient helps us know how the defect localization and prediction task loss changes with the parameters under the current parameters. By adjusting the parameters of the shared feature extraction layer and updating them according to the direction and magnitude of the second gradient, the defect localization and prediction task loss can be gradually reduced, improving the accuracy of defect localization and prediction.
[0110] Step S363: Perform gradient consistency analysis on the first gradient and the second gradient, and calculate the gradient direction cosine similarity. The closer the direction cosine similarity value is to 1, the higher the degree of consistency of the gradient directions of the two tasks. The closer it is to -1, the higher the degree of gradient direction conflict.
[0111] The cosine similarity of gradient directions is used to measure the consistency of gradient directions. Cosine similarity is a commonly used method to measure the similarity of vector directions, obtained by dividing the dot product of two vectors by the product of their magnitudes. For the first and second gradients, they are treated as vectors, and their cosine similarity is calculated. The value of cosine similarity ranges from -1 to 1. When the cosine similarity value is closer to 1, it indicates that the directions of the first and second gradients are closer, meaning that the gradient directions of the two tasks are more consistent. This implies that the two tasks have similar needs in parameter updates and can more easily perform joint parameter updates. When the cosine similarity value is closer to -1, it indicates that the directions of the first and second gradients are more opposite, meaning that the gradient directions of the two tasks conflict more. This implies that there is a significant contradiction in parameter updates between the two tasks, requiring special methods to handle this conflict. When the cosine similarity value is close to 0, it indicates that the directions of the two gradients are almost unrelated.
[0112] Step S364: When the gradient direction similarity is higher than the preset range, the first gradient and the second gradient are directly weighted and summed according to the dual-task dynamic weights to generate a shared gradient.
[0113] When the direction cosine similarity between the first gradient and the second gradient is higher than the preset range, it indicates that the gradient directions of the test case generation task and the defect location prediction task are relatively consistent. In this case, the first gradient and the second gradient can be directly weighted and summed according to the dynamic weights of the two tasks to generate a shared gradient.
[0114] The dual-task dynamic weights are weights dynamically adjusted based on the performance of the two tasks in the preceding steps. These weights reflect the importance of the test case generation task and the defect localization and prediction task in the current training phase. For example, if the accuracy of the test case generation task is low, its corresponding dynamic weight will be high; if the accuracy of the defect localization and prediction task is high, its corresponding dynamic weight will be low.
[0115] Step S365: When the similarity is below the preset range, the gradient projection method is used to project the conflicting gradients to the same direction, and then the weighted summation is used to generate the shared gradient.
[0116] When the cosine similarity between the directions of the first and second gradients is below a preset range, it indicates a conflict in the gradient directions of the test case generation task and the defect localization prediction task. In this case, the gradient projection method is used to project the conflicting gradients to a consistent direction.
[0117] For example, firstly, a consistent direction is determined. This consistent direction can be a linear combination of the two gradients or a direction pre-defined based on the characteristics of the task. Then, the first and second gradients are projected onto this consistent direction. The projection operation can be implemented using the dot product of vectors and the projection formula. After projection, the projected gradients are weighted and summed according to the dynamic weights of the two tasks to generate a shared gradient. Similarly, the projected gradients are weighted according to the dynamic weights of the test case generation task and the defect localization prediction task, and then summed to obtain the shared gradient. The shared gradient obtained in this way not only solves the problem of gradient direction conflict but also considers the importance of the two tasks. It can better balance the needs of the two tasks when updating the parameters of the shared feature extraction layer, avoiding model performance degradation due to gradient conflict.
[0118] Step S366: Perform gradient clipping on the shared gradient to control the gradient norm within a preset range to avoid gradient explosion. During clipping, the gradient direction is preserved, and only the gradient magnitude is adjusted.
[0119] The purpose of gradient clipping is to control the gradient norm within a preset range. The gradient norm is the magnitude of the gradient vector, representing the size of the gradient. The preset range is a threshold set based on actual conditions. When the gradient norm exceeds this threshold, the gradient needs to be clipped. During clipping, the gradient direction is preserved, and only the gradient magnitude is adjusted. Specifically, if the norm of a shared gradient is greater than the preset range, the shared gradient vector is divided by its norm and then multiplied by the value of the preset range. This ensures that the gradient direction remains unchanged, only adjusting the gradient magnitude to within the preset range.
[0120] Step S367: Update the parameters of the clipped shared gradient based on the momentum optimizer. The momentum term integrates the historical gradient direction to accelerate convergence and suppress oscillations. The learning rate dynamically decays with each training round. The initial learning rate is set, and the later learning rate is adjusted.
[0121] During training, the learning rate dynamically decreases with each training epoch. The initial learning rate is set to a relatively large value at the start of training, allowing the model to quickly converge to a roughly optimal region in the early stages. As the number of training epochs increases, the learning rate gradually decreases. Later adjustments to the learning rate allow for more precise parameter adjustments as the model approaches the optimal solution, preventing it from missing the optimal solution due to excessively large step sizes.
[0122] For example, the initial learning rate can be set to 0.01. Then, during training, after a certain number of training epochs, the learning rate is multiplied by a decay factor (such as 0.9). In this way, as training progresses, the learning rate gradually decreases, making the model's convergence process more stable and accurate. Through the momentum optimizer and the dynamically decaying learning rate, the parameters of the shared feature extraction layer can be effectively updated, allowing the model to continuously optimize in dual-task collaborative training, eventually converging to a better state and generating an accurate set of test case generation parameters.
[0123] Step S400: Input the test case generation parameter set into the generator of the adversarial generative network, and strengthen the feature representation of the boundary test scenario through feature adversarial learning with the discriminator to generate the boundary test case set.
[0124] In one implementation, step S400 may specifically include the following steps S410 to S460: Step S410: Construct an adversarial generative network containing a generator and a discriminator. The generator uses a hybrid architecture of transposed convolution and recurrent network to generate test case features, and the discriminator uses a convolutional network architecture to distinguish between real and generated test cases. The input of both is the test case feature vector.
[0125] The generator's role is to generate test case features based on the input, employing a hybrid architecture of transposed convolutions and recurrent networks. A transposed convolutional layer (also called a deconvolutional layer) is a neural network layer used for upsampling, transforming low-resolution feature maps into high-resolution ones. In the generator, this progressively increases the feature dimensionality, resulting in richer and more detailed generated features. For example, when generating the input parameter sequence for test cases, the transposed convolutional layer can expand the initial low-dimensional features into more expressive high-dimensional features.
[0126] Recurrent networks (such as LSTM or GRU) are used to model the dependencies between test case steps. Test cases are typically a series of steps in a sequential order. Recurrent networks can remember information from previous steps and update them based on the current input and previous states, thereby generating a logical sequence of test case steps.
[0127] The discriminator employs a convolutional network architecture. Convolutional networks are highly capable in image recognition and feature extraction, and are equally suitable for distinguishing between real and generated test cases. Convolutional layers perform sliding convolution operations on the input test case feature vector using convolution kernels, extracting local features and patterns from the test case features. Through a combination of multiple convolutional and pooling layers, the discriminator can progressively extract higher-level features, thereby determining whether the input test case feature vector is real or generated.
[0128] Both the generator and the discriminator are inputs to test case feature vectors. For the generator, the input test case feature vector can be the result of concatenating the test case generation parameter set with a random noise vector; the addition of the random noise vector increases the diversity of the generated data. For the discriminator, the input test case feature vector can be either the feature vector of real samples extracted from the historical test case library or the candidate boundary test case feature vector generated by the generator.
[0129] Step S420: Concatenate the test case generation parameter set with the random noise vector as input to the generator. The generator gradually increases the feature dimension through transposed convolutional layers and models the dependencies between test case steps through recurrent layers, outputting the candidate boundary test case feature vector.
[0130] After receiving the input, the generator first uses transposed convolutional layers to progressively increase the feature dimensionality. The transposed convolutional layers transform the low-dimensional input feature map into a high-dimensional feature map through the reverse operation of the convolutional kernel. In this process, the transposed convolutional layers continuously learn and capture information from the input features, expanding them into richer and more detailed feature representations. For example, when processing input parameters for test cases, the transposed convolutional layers can expand the initial parameter features into high-dimensional features containing more semantic and contextual information.
[0131] Next, the generator models the dependencies between test case steps using recurrent layers. These recurrent layers remember previous step information and update them based on the current input and previous states, thus generating a logically ordered sequence of test case steps. For example, when generating the execution steps of a test case, the recurrent layer can predict subsequent steps based on preceding steps, ensuring the coherence and rationality between steps. The output of the recurrent layer is combined with the features enhanced by the transposed convolutional layer to form a more complete feature representation of the test cases. Finally, the generator outputs candidate boundary test case feature vectors. These feature vectors contain feature information about the generated test cases in terms of input parameters, execution steps, etc., and also have a feature representation of the boundary test scenario. These candidate boundary test case feature vectors will serve as input to the subsequent discriminator for comparison and differentiation with the feature vectors of the true boundary test cases.
[0132] Step S430: Collect boundary test cases from the historical test case library, extract their feature vectors as real samples, and input them together with the candidate boundary test case feature vectors output by the generator into the discriminator. The discriminator performs multi-scale feature extraction on the input feature vectors and outputs the true and false probabilities through a fully connected layer. The expected probability of the real sample is the reference value one, and the expected probability of the generated sample is the reference value zero.
[0133] Collect boundary test cases from the historical test case library. These boundary test cases were designed for the boundary conditions of the software system during previous testing processes and contain rich information on boundary test scenarios. Extract features from these boundary test cases and convert them into feature vectors, which serve as real samples. The feature extraction process can employ methods similar to those used in generators and discriminators, such as using convolutional layers to extract local features and using pooling layers for feature dimensionality reduction.
[0134] The feature vectors of real samples and the feature vectors of candidate boundary test cases output by the generator are jointly input into the discriminator. The discriminator's task is to distinguish whether these input feature vectors are real or generated. The discriminator first performs multi-scale feature extraction on the input feature vectors. Multi-scale feature extraction refers to analyzing and extracting input features at different scales. By using convolutional kernels of different sizes and different convolutional layer structures, it is possible to capture feature information of different levels and granularities in the input features. For example, using a smaller convolutional kernel can extract detailed features from the input features, while using a larger convolutional kernel can extract more macroscopic features.
[0135] After multi-scale feature extraction, the discriminator processes the extracted features through a fully connected layer. The fully connected layer integrates and maps all the features, outputting a scalar value representing the probability that the input feature vector is a real sample. For real samples, the discriminator is expected to output a probability of the reference value one, meaning the discriminator can accurately identify real samples; for generated samples, the discriminator is expected to output a probability of the reference value zero, meaning the discriminator can accurately identify generated samples.
[0136] In this way, the discriminator continuously learns and distinguishes between real samples and generated samples, improving its discrimination ability. At the same time, it also prompts the generator to continuously improve the feature vector of the generated candidate boundary test cases, making it closer to the features of real samples.
[0137] Step S440: Calculate the cross-entropy loss of the discriminator between real samples and generated samples, use it as the discriminator loss, update the discriminator parameters through backpropagation to improve the ability to distinguish between real and fake samples.
[0138] For real samples, the closer the probability output by the discriminator is to the reference value of one, the more accurate the discriminator's identification of real samples is; for generated samples, the closer the probability output by the discriminator is to the reference value of zero, the more accurate the discriminator's identification of generated samples is. Cross-entropy loss is calculated based on the difference between the discriminator's output probability and the expected probability; the greater the difference, the greater the cross-entropy loss. The gradient of the discriminator parameters is calculated with respect to the discriminator loss using the backpropagation algorithm. Backpropagation is an efficient method for calculating the gradient of the loss function with respect to network parameters. Using the chain rule, it starts with the loss function and propagates backward step by step to calculate the gradient of each network layer. Based on the calculated gradients, the discriminator parameters are updated using an optimization algorithm (such as stochastic gradient descent).
[0139] With each parameter update, the discriminator's ability to distinguish between real and generated samples improves. As training progresses, the discriminator becomes more accurate in identifying real and generated samples, prompting the generator to continuously improve the feature vectors of the generated candidate boundary test cases, making them more difficult for the discriminator to distinguish and further improving the quality of the generated boundary test cases.
[0140] Step S450: Fix the discriminator parameters and calculate the probability that the generator-generated sample is judged as a real sample by the discriminator. The probability is positively correlated with the generator loss. At the same time, feature matching loss is introduced to calculate the distance between the generated sample and the real sample in the intermediate layer features of the discriminator. The total generator loss is the sum of the adversarial loss and the feature matching loss.
[0141] In one implementation, step S450 may specifically include the following steps S451 to S456: Step S451: After fixing the discriminator network parameters, the test case generation parameter set is concatenated with a random noise vector that follows a Gaussian distribution and input into the transposed convolutional layer of the generator. The upsampling operation generates candidate boundary test case feature vectors with dimensions consistent with the real samples.
[0142] After fixing the discriminator network parameters, a new round of training begins on the generator. The test case generation parameter set is concatenated with a random noise vector following a Gaussian distribution to form the generator's input. The test case generation parameter set contains important information about test case generation learned in previous steps, while the addition of the random noise vector introduces randomness into the generation process, making the generated test cases more diverse.
[0143] The concatenated vectors are input into the transposed convolutional layer of the generator. The transposed convolutional layer uses upsampling to transform the low-dimensional input feature map into a high-dimensional feature map, gradually increasing the feature dimension. Upsampling is the core function of the transposed convolutional layer; through the inverse operation of the convolutional kernel, it interpolates and expands the input feature map, increasing its size. In this process, the transposed convolutional layer learns how to expand low-dimensional features into high-dimensional features based on the input parameters and its own weights, generating richer and more detailed feature representations.
[0144] Step S452: Input the candidate feature vector into the discriminator, extract the true and false probability values of the output of the fully connected layer of the discriminator, construct the adversarial loss function based on the probability value, and calculate the loss value of the generated sample being misclassified as a real sample using the binary classification cross-entropy formula.
[0145] The candidate boundary test case feature vectors generated by the generator are input into the discriminator. After receiving the input, the discriminator performs a series of processes on the candidate feature vectors, including multi-scale feature extraction and mapping by fully connected layers, and finally outputs a true / false probability value, representing the probability that the candidate feature vector is a real sample.
[0146] An adversarial loss function is constructed based on the true / false probabilities output by the fully connected layer of the discriminator. The purpose of the adversarial loss function is to measure the degree to which the discriminator misclassifies samples generated by the generator as real samples. In this task, since the generator's goal is to make the discriminator misclassify the generated samples as real samples, the adversarial loss function needs to reflect the difference between the discriminator's judgment of the generated samples and the generator's expectation.
[0147] The loss value for a generated sample being misclassified as a real sample is calculated using the binary cross-entropy formula. In this scenario, the expected probability of a generated sample is the reference value of zero (i.e., the desired probability that the discriminator will classify it as a generated sample), while the true / false probability value output by the discriminator is the probability that the generated sample is classified as a real sample. The two probabilities are compared using the binary cross-entropy formula to calculate the loss value. A larger loss value indicates a higher probability that the generated sample is correctly identified by the discriminator, and a worse performance of the generator; a smaller loss value indicates that the generated sample is closer to the real sample, and a better performance of the generator.
[0148] By minimizing the adversarial loss function, the generator continuously adjusts its parameters to strive to generate samples that can deceive the discriminator, thereby improving the quality and authenticity of the generated samples.
[0149] Step S453: Extract the feature maps output by the discriminator convolutional layer layer by layer, calculate the Euclidean distance between the feature maps of the generated sample and the real sample at the same level, and sum the feature matching loss by layer depth. The feature weight of the deeper features is higher than that of the shallow features.
[0150] Because the deeper features of a discriminator typically contain higher-level and more abstract feature information, they are more important for distinguishing between real and generated samples, and therefore receive higher weights. For example, the feature maps output by deeper convolutional layers of the discriminator will have greater weights than those output by shallower convolutional layers. This weighted summation method can more accurately reflect the differences in overall features between generated and real samples.
[0151] Minimizing the feature matching loss can make the generated samples more similar to the real samples at the feature level. The generator adjusts its parameters based on the gradient of the feature matching loss, making the generated samples more similar to the real samples in the feature maps output by each convolutional layer of the discriminator, thereby improving the quality and realism of the generated samples.
[0152] Step S454: Introduce a multimodal boundary feature constraint term, extract the semantic-code-defect triple boundary feature template from the multimodal associated feature space, calculate the cosine similarity between the generated sample and the template, and include the difference value with similarity below the threshold in the total loss calculation.
[0153] In one implementation, step S454 includes the following steps S4541 to S4546: Step S4541: Perform periodic updates to the triple boundary feature template library, filter templates through discriminator feedback, and eliminate redundant templates with coverage exceeding a preset threshold. The template update cycle is linked to the generator training rounds.
[0154] The triple boundary feature template library is a collection storing semantic-code-defect triple boundary feature templates, containing a series of representative boundary feature patterns. As the generator trains and tests, the boundary testing scenarios may change, some templates may become inapplicable, and new boundary feature patterns may be discovered. The discriminator analyzes and judges the input features during the process of distinguishing between real and generated samples, providing information on which templates can effectively constrain the generated samples. Based on the discriminator's feedback, the templates in the template library are evaluated and filtered. A preset threshold is a standard set according to actual conditions. When the coverage of a template in generated samples exceeds this threshold, it indicates that the template has been overused in generated samples and may be a redundant template. The existence of redundant templates increases computational cost and training complexity, and may also limit the diversity of the generator. Therefore, these redundant templates are removed from the template library to ensure its conciseness and effectiveness.
[0155] The template update cycle is linked to the generator training rounds. In other words, the template update frequency is related to the generator's training progress. For example, in the early stages of generator training, the template update cycle can be relatively short to adapt to changes in the generator; as generator training progresses, the template update cycle can be appropriately extended to ensure the stability of the template library. This linkage mechanism ensures that the triple boundary feature template library always matches the generator's training state, providing more effective constraints and guidance for the generator.
[0156] Step S4542: Perform modal decomposition on the generated sample feature vector to separate semantic dependency feature sub-vectors, code path feature sub-vectors and defect propagation feature sub-vectors, and calculate the cosine similarity with the templates of the corresponding categories in the template library.
[0157] The semantic dependency feature sub-vector reflects the characteristics of the generated samples in terms of semantic dependency relationships within business rules, including the associations and hierarchical structure between semantic components in the generated samples. The code path feature sub-vector reflects the characteristics of the generated samples in terms of code execution path dependencies, including the execution order of code and function call relationships. The defect propagation feature sub-vector describes the characteristics of the generated samples in terms of defect propagation chain relationships, such as the location of defect introduction, propagation path, and scope of impact.
[0158] The cosine similarity of each separated sub-vector is calculated with the corresponding template in the template library. The template library contains templates for three categories: semantic, code, and defect, each corresponding to a boundary feature pattern of a different modality. By calculating the cosine similarity, the similarity between the generated sample's features in each modality and the corresponding template can be measured. For example, calculating the cosine similarity between the semantic dependency feature sub-vector and the semantic template in the template library yields the degree of matching between the generated sample and the template in the semantic modality; similar calculations are performed on the code path feature sub-vector and the defect propagation feature sub-vector.
[0159] Step S4543: Dynamically adjust the semantic template similarity threshold based on the business rule hierarchy tree. The threshold corresponding to the root node rule is higher than that of the child node rule. The code template threshold is positively correlated with the path complexity, and the defect template threshold is positively correlated with the propagation impact range.
[0160] To more reasonably assess the similarity between generated samples and templates, the semantic template similarity threshold is dynamically adjusted based on a hierarchical business rule tree. In this hierarchical tree, the root node represents the highest-level business rule, and child nodes represent lower-level business rules. Business rules at different levels may differ in importance and binding force; therefore, the semantic template similarity threshold needs to be adjusted according to the hierarchy of the business rules.
[0161] The threshold for root node rules is higher than that for child node rules. This is because root node rules typically represent the core rules and key logic of the business, and impose stricter semantic constraints on the generated samples. If the generated samples have low similarity to the semantic template corresponding to the root node rule, it indicates that the generated samples may have significant deviations in the core business logic, requiring greater attention and penalty. Child node rules, on the other hand, are relatively less important, and the similarity requirements can be more relaxed.
[0162] The code template threshold is positively correlated with path complexity. Code path complexity reflects the complexity of the code execution path, such as the number and nesting depth of conditional branches, loop structures, etc. Higher path complexity indicates more complex code execution logic, and thus higher requirements for the generated samples in terms of code execution path. Therefore, when code path complexity is high, the code template threshold should be increased to require the generated samples to have a higher similarity to the template in terms of code path features; when path complexity is low, the code template threshold should be appropriately decreased.
[0163] The defect template threshold is positively correlated with the scope of its propagation. The scope of defect propagation refers to the range of code modules and functions that a defect may affect. The larger the scope of propagation, the greater the harm of the defect, and the higher the requirements for the generated samples in terms of defect propagation characteristics. Therefore, when the scope of defect propagation is large, the defect template threshold should be increased, requiring the generated samples to have a higher similarity to the template in terms of defect propagation characteristics; when the scope of propagation is small, the defect template threshold should be appropriately decreased.
[0164] Step S4544: Perform a weighted summation of similarity differences below the threshold. The weight of semantic feature differences increases with the rule level, the weight of code feature differences increases with the path complexity, and the weight of defect feature differences increases with the expansion of the scope of influence.
[0165] Step S4545: Fuse the weighted difference value with the feature matching loss. The proportion of the difference value is dynamically adjusted according to the current multimodal feature consistency evaluation result. When the consistency is low, the weight of the difference value is increased.
[0166] Multimodal feature consistency evaluation assesses the feature consistency of generated samples across three modalities: semantics, code, and defects. Low multimodal feature consistency indicates poor coordination between generated samples and different modalities, potentially suggesting mismatches between features from certain modalities. In such cases, increasing the weight of the weighted difference value in the fusion loss emphasizes the requirement for the generated samples to match the template across each modality, thus encouraging the generator to pay more attention to consistency across different modalities.
[0167] For example, when the multimodal feature consistency evaluation results show significant differences in semantic and code modal features between generated samples, increasing the weight of the weighted difference value allows the generator to focus more on adjusting semantic and code features during training, thereby improving the matching degree with the template and the consistency of multimodal features. Conversely, if the multimodal feature consistency is high, it indicates that the generated samples have good coordination across different modalities. In this case, the weight of the weighted difference value can be appropriately reduced, and more attention can be paid to feature matching loss to further improve the similarity between generated samples and real samples at the feature level.
[0168] Step S4546: After each round of template matching, calculate the cross-consistency score of semantic-code-defect features. When the score is lower than the preset threshold, trigger template library reconstruction, reclassify template categories through spectral clustering algorithm, and optimize the coverage uniformity of boundary features.
[0169] When the cross-consistency score is below a preset threshold, it indicates poor coordination between the generated samples and features of different modalities, suggesting potential mismatches between features of certain modalities and those of other modalities. In this case, template library reconstruction is triggered. The purpose of template library reconstruction is to re-divide and reorganize the templates in the template library to improve the uniformity and effectiveness of template coverage of boundary features. Spectral clustering is a graph-based clustering algorithm that treats data points as nodes in a graph. It constructs an adjacency matrix by calculating the similarity between nodes, then performs eigenvalue decomposition on the adjacency matrix and clusters the nodes based on the eigenvectors. In this scenario, templates are treated as data points, an adjacency matrix is constructed based on the similarity between templates (such as semantic similarity, structural similarity, etc.), and then the spectral clustering algorithm is used to classify the templates into different categories.
[0170] By reclassifying templates using spectral clustering algorithms, we can discover the underlying structures and relationships between templates, grouping similar templates together and assigning different templates to different categories. This optimizes the uniformity of boundary feature coverage, enabling the template library to better cover various boundary testing scenarios and providing the generator with more comprehensive and effective constraints. Simultaneously, the reconstructed template library can better adapt to changes in generated samples, improving the generator's ability to generate samples that meet the requirements of boundary testing scenarios.
[0171] Step S455: Construct a dynamic weight adjustment mechanism to dynamically adjust the ratio of adversarial loss and feature matching loss based on the boundary feature coverage of the generated samples. When the coverage is low, increase the weight of feature matching loss; when the coverage is high, increase the weight of adversarial loss.
[0172] The purpose of constructing a dynamic weight adjustment mechanism is to flexibly adjust the proportions of adversarial loss and feature matching loss in the generator's total loss based on the actual situation of the generated samples. Adversarial loss measures the degree to which the samples generated by the generator are misclassified as real samples by the discriminator, while feature matching loss measures the similarity between the generated samples and real samples at the feature level.
[0173] The boundary feature coverage of generated samples reflects the degree to which they cover the features of the boundary test scene. Low coverage indicates that the generated samples do not adequately represent the features of the boundary test scene, requiring more attention to feature matching loss. In this case, increasing the weight of feature matching loss encourages the generator to focus more on the similarity between generated and real samples at the feature level during training, striving to cover more boundary test scene features. Conversely, high coverage indicates that the generated samples have already covered the boundary test scene features well, allowing for greater focus on adversarial loss. Increasing the weight of adversarial loss prompts the generator to further improve the realism of the generated samples, making it more difficult for the discriminator to distinguish between generated and real samples.
[0174] For example, in the early stages of generator training, the boundary feature coverage of generated samples may be low. At this time, the weight of the feature matching loss is set higher to guide the generator to learn the feature patterns of real samples. As training progresses, the boundary feature coverage of generated samples gradually increases. At this time, the weight of the feature matching loss is gradually reduced, and the weight of the adversarial loss is increased, making the generator more focused on deceiving the discriminator.
[0175] Step S456: Calculate the gradient of the total loss with respect to the generator parameters using the backpropagation algorithm, update the weight parameters of the transposed convolutional layer and the recurrent layer using the Adam optimizer, and iterate until the loss function value converges to the preset range, thus completing one round of generator parameter update.
[0176] The Adam optimizer is an optimization algorithm that combines momentum optimization and adaptive learning rate. It adaptively adjusts the learning rate of each parameter while using a momentum term to accelerate convergence. In each iteration, the Adam optimizer updates the weight parameters of the transposed convolutional layer and the recurrent layer based on the calculated total gradient and its own update rule.
[0177] The optimization process iterates until the loss function converges to a preset range. After each parameter update, the generator's total loss is recalculated, and the convergence of the loss function to the preset range is checked. The preset range is a threshold set based on actual conditions. When the loss function value is less than this threshold, the generator is considered to have converged to a good state, and the iteration stops. During the iteration process, as the parameters are continuously updated, the generator continuously adjusts its output, making the generated samples increasingly closer to the real samples and better meeting the requirements of the boundary test scenario. After one round of generator parameter updates, the generator's performance is improved, enabling it to generate samples that better meet the requirements of the boundary test scenario. This process is repeated until the generator achieves satisfactory training results, ultimately generating a high-quality set of boundary test cases.
[0178] Step S460: Perform backpropagation based on the generator's total loss, update the generator parameters, iteratively execute the discriminator update and generator update process, calculate the boundary feature coverage of the generated samples after each iteration, stop training when the coverage reaches a preset range, convert the candidate boundary test case feature vector output by the generator into a structured test case description, and generate a set of boundary test cases.
[0179] The process iteratively updates the discriminator and the generator. The discriminator is updated to improve its ability to distinguish between real and generated samples, while the generator is updated to generate more realistic samples to deceive the discriminator. In each iteration, the discriminator's parameters are updated first to better distinguish between real and generated samples; then, the discriminator's parameters are fixed, and the generator's parameters are updated to allow the generator to generate candidate boundary test case feature vectors that are closer to real samples.
[0180] Boundary feature coverage reflects the degree to which generated samples cover the boundary features of the test scene, and is an important indicator for evaluating the quality of samples generated by the generator. Boundary feature coverage is obtained by comparing the generated samples with a triple boundary feature template and statistically analyzing the proportion of boundary features that match the template.
[0181] When the boundary feature coverage of the generated samples reaches a preset range, it indicates that the generator has generated enough high-quality samples that meet the requirements of the boundary test scenario, and training stops at this point. The preset range is a threshold set based on actual conditions; when the boundary feature coverage exceeds this threshold, the generator training is considered to have achieved a satisfactory result.
[0182] Finally, the candidate boundary test case feature vectors output by the generator are converted into structured test case descriptions. A structured test case description is a standardized, easy-to-understand, and easy-to-execute way of expressing test cases, containing detailed information such as input parameters, execution steps, and expected results. By parsing and transforming the candidate boundary test case feature vectors into structured test case descriptions, a set of boundary test cases is generated.
[0183] Step S500: Perform priority sorting on the boundary test case set, calculate the test case coverage weight based on the semantic dependency relationship of business rules and the correlation relationship of defect propagation links, and generate a target test case set containing the priority sorting results.
[0184] In one implementation, step S500 may specifically include the following steps S510 to S560: Step S510: Construct a test case coverage weight calculation model. Its inputs are the semantic dependency features of business rules and the correlation features of defect propagation links corresponding to the boundary test cases, and its output is the comprehensive coverage weight.
[0185] The semantic dependency features of business rules are extracted from the semantic dependency network of business rules, containing the associations and hierarchical structure information between various semantic components in the business rules. The defect propagation link association features are extracted from the defect propagation link graph, describing the propagation path and scope of impact of defects in the software system. The use case coverage weight calculation model can employ a machine learning model, such as a multilayer perceptron (MLP). A multilayer perceptron is a feedforward neural network consisting of an input layer, hidden layers, and an output layer. In this model, the input layer receives the semantic dependency features of business rules corresponding to boundary test cases and the defect propagation link association features; the hidden layer performs nonlinear transformations and feature extraction on the input features; and the output layer outputs a scalar value, i.e., the comprehensive coverage weight.
[0186] When building the model, input features need to be preprocessed, such as normalized, to ensure consistent scale across different features and prevent any single feature from having an excessive impact on the model. Simultaneously, a large amount of training data is required to train the model. This training data can include historical test cases and their corresponding semantic dependency features of business rules, defect propagation chain correlation features, and actual coverage weights. Through training, the model can learn the mapping relationship between input features and comprehensive coverage weights, thereby accurately calculating the comprehensive coverage weight of each boundary test case.
[0187] Step S520: Extract rule-level features from the semantic dependency relationship of business rules. The test case weight configuration of the root node rule is higher than that of the child node rule. The dependency depth between rules is associated with the weight. Calculate the weight of business rules through the node depth of the semantic dependency network.
[0188] The semantic dependency relationships of business rules can be represented by a semantic dependency network, where nodes represent semantic components in the business rules, and edges represent the associations and dependencies between semantic components. The hierarchical feature of rules reflects the hierarchical structure of business rules in the semantic dependency network. The root node rule is located at the highest level of the semantic dependency network, representing the core rules and key logic of the business; the child node rules are located at lower levels and are refinements and extensions of the root node rule.
[0189] Test cases corresponding to root node rules should have higher weights than those corresponding to child node rules. This is because root node rules play a crucial role in the normal operation of the business; a test case that covers a root node rule has greater importance during testing. For example, in an e-commerce system, the root node rule might be "user places an order," and child node rules might be "select product specifications" or "enter shipping address." Test cases covering the "user places an order" rule should have higher weights than test cases covering the "select product specifications" rule.
[0190] Dependency depth and weight association between rules. Dependency depth refers to the depth of a rule relative to the root node in the semantic dependency network. The greater the depth, the farther the rule is from the root node, and the lower its relative importance. The weight of business rules is calculated based on the node depth of the semantic dependency network. A corresponding weight coefficient can be set for each node depth; the greater the node depth, the smaller the weight coefficient.
[0191] In this way, business rule weights can be reasonably assigned to each test case based on the hierarchical structure and dependencies of business rules, so that the priority of test cases can better reflect the importance of business rules.
[0192] Step S530: Extract the propagation impact features from the defect propagation link relationship. The propagation path length is associated with the weight, and the number of affected modules is associated with the weight. The defect impact weight is calculated by multiplying the propagation probability by the number of affected modules.
[0193] The relationship between defect propagation links can be represented by a defect propagation link graph, where nodes represent the defect's introduction location, triggering condition, and scope of influence, and edges represent the defect's propagation path. Propagation impact characteristics mainly include the propagation path length and the number of affected modules. The propagation path length refers to the length of the path the defect takes from its introduction location to its final impact area. The longer the path length, the more complex the defect propagation process and the wider the potential impact. Therefore, the longer the propagation path length, the higher the weight of the corresponding test case.
[0194] The number of affected modules is correlated with their weight. The number of affected modules refers to the number of code modules that a defect may impact. A larger number of affected modules indicates a wider scope of impact and greater harm to the software system. Therefore, the more affected modules, the higher the weight of the corresponding test cases. For example, if a defect may affect multiple core business modules, then test cases covering the scope of that defect's impact will have a higher priority.
[0195] The defect impact weight is calculated by multiplying the propagation probability by the number of affected modules. The propagation probability refers to the likelihood of a defect spreading from one node to another, reflecting the ease or difficulty of defect propagation. Multiplying the propagation probability by the number of affected modules provides a more comprehensive reflection of the degree of defect propagation impact. For example, if a defect has a high propagation probability and affects a large number of modules, its defect impact weight will be relatively high.
[0196] Step S540: Calculate the code path coverage weight of the test cases. Test cases that cover code paths not covered by other test cases receive an additional weight bonus. The uniqueness of path coverage is related to the bonus ratio. The uniqueness coefficient is calculated through the path coverage matrix.
[0197] Code path coverage refers to the code paths a test case traverses during execution, reflecting the extent to which the test case covers the code. The wider the code paths a test case covers, the more effective it is in discovering potential defects in the code.
[0198] Test cases that cover code paths not covered by other test cases receive an extra weighting. This is because these uncovered paths may be unique or easily overlooked, potentially harboring more hidden defects. Therefore, a test case that covers these uncovered paths is more important and should receive additional weighting.
[0199] Path coverage uniqueness refers to the proportion of code paths covered by a test case that are not covered by other test cases. A higher proportion indicates more unique path coverage and a greater contribution to discovering potential defects. Therefore, higher path coverage uniqueness results in a higher bonus. A path coverage matrix is a two-dimensional matrix where rows represent test cases and columns represent code paths. Elements in the matrix indicate whether a particular test case covers a specific code path. By analyzing and calculating the path coverage matrix, the path coverage uniqueness coefficient for each test case can be obtained. For example, the number of code paths covered by each test case that are not covered by other test cases can be calculated, and then divided by the total number of paths covered by that test case to obtain the path coverage uniqueness coefficient.
[0200] Based on the calculated uniqueness coefficient and the preset bonus ratio, an additional weight is calculated for each test case. Finally, the code path coverage weight and the additional weight are added together to obtain the final code path coverage weight of the test case. This allows the priority of test cases to better reflect their coverage and uniqueness of the code path, and more effectively discover potential defects in the code.
[0201] Step S550: Normalize the business rule weight, defect impact weight, and code path coverage weight respectively. Then, sum the normalized weights to generate the comprehensive coverage weight of the test cases. The weight allocation is determined based on the contribution of each factor to the effectiveness of the test.
[0202] Different normalization methods can be used for business rule weights, defect impact weights, and code path coverage weights. For example, a min-max normalization method can be used, where each weight is subtracted from its minimum value, and then divided by the difference between its maximum and minimum values to obtain the normalized weight. This ensures that each normalized weight is between 0 and 1.
[0203] The normalized weights are then summed using a weighted average to generate the overall coverage weights for the test cases. During this weighted summation, a weight coefficient needs to be assigned to each normalized weight. These coefficients are determined based on the contribution of each factor to the test's effectiveness. For example, if business rules contribute significantly to test effectiveness, the weight coefficient for business rules can be set higher; similarly, if defect impact contributes significantly to test effectiveness, the weight coefficient for defect impact can be set higher.
[0204] By allocating weight coefficients reasonably, the impact of multiple factors such as business rules, defect impact, and code path coverage on test case priority can be comprehensively considered, so that the comprehensive coverage weight can more accurately reflect the importance of each test case.
[0205] Step S560: Sort the boundary test case set according to the comprehensive coverage weight from high to low. Test cases with the same weight are sorted from high to low according to the business rule level. Test cases with the same level are sorted from large to small according to the defect impact scope. Generate a target test case set containing the priority sorting results.
[0206] The overall coverage weight, calculated in the previous steps, comprehensively considers multiple factors such as business rule weight, defect impact weight, and code path coverage weight, accurately reflecting the importance of each test case. Test cases with higher overall coverage weights are prioritized and executed first; test cases with lower overall coverage weights are executed later.
[0207] When test cases with the same weight exist, they are sorted from highest to lowest according to the business rule hierarchy. The business rule hierarchy reflects the importance and priority of the business rules; the test case weight configuration for root node rules is higher than that for child node rules. Therefore, for test cases with the same overall coverage weight, the test case covering the higher business rule hierarchy is preferred. For example, if two test cases have the same overall coverage weight, but one covers the root node business rule and the other covers the child node business rule, then the test case covering the root node business rule is preferred. When the business rule hierarchy is also the same, they are sorted from largest to smallest according to the scope of defect impact. The scope of defect impact refers to the range of code modules and functions that a defect may affect; the larger the scope, the greater the harm of the defect. Therefore, for test cases with the same business rule hierarchy, the test case covering the larger scope of defect impact is preferred. For example, if two test cases cover the same business rule hierarchy, but one covers a defect whose impact involves multiple core business modules and the other covers a defect whose impact only involves one secondary business module, then the test case covering the larger scope of defect impact is preferred.
[0208] Figure 2 A hardware entity diagram of a computer system provided as an embodiment of the present invention, such as... Figure 2 As shown, the hardware entity of the computer system 1000 includes a processor 1001 and a memory 1002, wherein the memory 1002 stores a computer program that can run on the processor 1001, and the processor 1001 executes the program to implement the steps in the method of any of the above embodiments.
Claims
1. A test case generation method based on multimodal machine learning and dynamic optimization, characterized in that, The method includes: Cross-modal feature association processing is performed on the semantic text of requirements, source code instruction flow and historical defect event records in software testing scenarios to generate a multimodal association feature space containing semantic dependencies of business rules, dependencies of code execution paths and associations of defect propagation links; The multimodal associated feature space is input into the dynamic attention alignment network. The semantic dependency relationship of business rules, the dependency relationship of code execution path and the defect propagation link are dynamically weighted by calculating the feature interaction intensity between modalities, and a unified joint representation vector with cross-modal constraints is generated. The unified joint representation vector is subjected to dual-task collaborative training of test case generation and defect localization prediction. The feature extraction weights of the two tasks are adjusted by sharing gradient backpropagation between tasks to generate a test case generation parameter set. The test case generation parameter set is input into the generator of the adversarial generative network, and the feature representation of the boundary test scenario is strengthened through feature adversarial learning with the discriminator to generate the boundary test case set. Priority sorting is performed on the boundary test case set, and test case coverage weights are calculated based on the semantic dependency relationship of business rules and the correlation relationship of defect propagation links to generate a target test case set containing the priority sorting results.
2. The method according to claim 1, characterized in that, The process involves performing cross-modal feature association processing on the semantic text of requirements, source code instruction flow, and historical defect event records in software testing scenarios to generate a multimodal association feature space containing semantic dependencies of business rules, dependencies of code execution paths, and associations of defect propagation chains. This includes: The semantic text of the requirement is parsed using a two-layer approach of semantic role labeling and dependency syntax to identify the argument roles of the core predicates and construct a semantic dependency network containing role hierarchy relationships, wherein the semantic dominance relationship between argument roles is represented by directed edges. The source code instruction flow is subjected to a fusion analysis of function call graph and control flow graph, the dependency relationship between function entry parameters and return values is extracted, the jump logic of conditional branch statements is traced, and a code execution path network containing the execution order of basic blocks and data dependency relationship is generated. The path nodes are marked with execution frequency and branch conditions. A time-series correlation analysis is performed on the historical defect event records to extract the correlation between defect reports and code submissions, and a propagation link map of defect introduction location, triggering conditions and impact range is constructed. The propagation probability and the number of affected modules are marked on the link edges. The semantic dependency network, code execution path network, and defect propagation link graph are input into the cross-modal association engine to calculate the semantic similarity between semantic nodes and code nodes, the path overlap between code nodes and defect nodes, and the description matching degree between semantic nodes and defect nodes, generating a three-dimensional association strength matrix. Based on the three-dimensional association strength matrix, association modeling is performed on the three modal features. Through intra-modal feature clustering and inter-modal feature alignment, a heterogeneous feature network containing semantic-code-defect triple association is constructed. Network nodes carry modality type labels and association strength attributes. A graph neural network is used to learn features from the heterogeneous feature network. Multimodal node information is fused through neighborhood aggregation and message passing mechanisms to generate a multimodal association feature space that preserves the topological structure and relationships.
3. The method according to claim 2, characterized in that, The process involves using a graph neural network to learn features from the heterogeneous feature network, fusing multimodal node information through neighborhood aggregation and message passing mechanisms to generate a multimodal association feature space that preserves topological structure and relationships. This includes: A three-layer graph neural network architecture is constructed, consisting of a modality discrimination embedding layer, a neighborhood aggregation layer, and an association enhancement layer. The modality discrimination embedding layer assigns initial embedding vectors to nodes of different modalities, the neighborhood aggregation layer fuses information from neighboring nodes, and the association enhancement layer enhances cross-modal association features. In the modality-discriminating embedding layer, initial semantic embeddings are generated by a pre-trained language model for semantic dependency network nodes, initial code embeddings are generated by a code pre-trained model for code execution path network nodes, and initial defect embeddings are generated by defect text encoding for defect propagation link graph nodes. The dimensions of the three embedding vectors are kept consistent. In the neighborhood aggregation layer, multi-hop neighborhood sampling is performed on each node. During sampling, nodes of the same modality and nodes interacting across modalities are selected first. The aggregation weight of neighboring nodes is calculated through an attention mechanism. The weight is positively correlated with the correlation strength between nodes, and preliminary aggregation features are generated. In the association enhancement layer, intermodal cross-attention calculation is performed on the preliminary aggregated features. Semantic nodes focus on the execution path features of code nodes and the propagation features of defective nodes. Code nodes focus on the argument role features of semantic nodes and the influence range features of defective nodes. Defective nodes focus on the predicate features of semantic nodes and the branch condition features of code nodes, thereby generating association enhancement features. The initial embedding vector is added to the association enhancement feature through residual connection, and after layer normalization, it is input into the next iteration. During the iteration, the neighborhood sampling radius is dynamically adjusted, and the sampling radius is used for the node pairs corresponding to the association strength. After the iteration is completed, the final embedding vectors of all nodes are extracted, and the dimensionality of the final embedding vectors is reduced by principal component analysis to generate a multimodal association feature space.
4. The method according to claim 1, characterized in that, The process involves inputting the multimodal associated feature space into a dynamic attention alignment network, and dynamically assigning weights to the semantic dependencies of business rules, the dependencies of code execution paths, and the correlations of defect propagation links through intermodal feature interaction strength calculation, thereby generating a unified joint representation vector with cross-modal constraints. This includes: A dynamic attention alignment network is constructed, which includes a modal interaction analysis module, a dynamic weight calculation module, and a feature fusion module. The modal interaction analysis module is used to calculate the feature interaction intensity, the dynamic weight calculation module is used to generate the weight allocation scheme, and the feature fusion module is used to generate the joint representation vector. The multimodal association feature space is input into the modal interaction analysis module to calculate the interaction strength between the semantic dependency relationship of business rules and the dependency relationship of code execution path, the interaction strength between the dependency relationship of code execution path and the association relationship of defect propagation link, and the interaction strength between the semantic dependency relationship of business rules and the association relationship of defect propagation link. The interaction strength is calculated by combining the feature co-occurrence frequency and the association strength matrix. An interaction intensity tensor is constructed based on the interaction intensity between three modes. The interaction intensity tensor is input into the dynamic weight calculation module. The main interaction component is extracted through tensor decomposition. The mode pairs corresponding to the main interaction component are assigned initial weights. Based on the initial weights, the semantic dependency relationship features of business rules, the code execution path dependency relationship features, and the defect propagation link relationship features are weighted to generate weighted modal features. During the weighting process, the weights are dynamically adjusted. When the variance of a certain modal feature deviates from the preset range, its weight is adjusted accordingly. The weighted modal features are input into the feature fusion module. The weighted semantic features and weighted code features are multiplied element-wise to obtain semantic-code fusion features. The semantic-code fusion features and weighted defect features are concatenated by channels to generate a preliminary joint representation vector. Cross-modal consistency verification is performed on the preliminary joint representation vector. The distribution similarity of the semantic feature part, code feature part and defect feature part is calculated. When the distribution of a certain part deviates from the overall distribution by more than a preset range, the corresponding modal weights are readjusted through the dynamic weight calculation module. The fusion process is repeated until the consistency constraint is met, and a unified joint representation vector is generated.
5. The method according to claim 4, characterized in that, The interaction intensity tensor is constructed based on the interaction intensity among the three modalities. This interaction intensity tensor is then input into a dynamic weight calculation module, and the main interaction components are extracted through tensor decomposition, including: An interaction intensity evaluation index system is constructed, which includes semantic consistency index, structural similarity index and temporal correlation index. The semantic consistency index is calculated by cosine similarity, the structural similarity index is calculated by graph edit distance, and the temporal correlation index is calculated by event co-occurrence window analysis. Calculate the scores of the semantic dependency relationship of business rules and the dependency relationship of code execution path on three indicators respectively, and sum them by weight to obtain the first interaction strength; The second interaction strength is obtained by calculating the scores of the code execution path dependency relationship and the defect propagation link relationship on three indicators and then summing them by weight. The scores of the semantic dependency relationship of business rules and the correlation relationship of defect propagation link on three indicators are calculated and weighted summed to obtain the third interaction strength. Three interaction intensities are used to construct an interaction intensity tensor, which is then input into the dynamic weight calculation module. The main interaction components are extracted through tensor decomposition, and the modal pairs corresponding to the main interaction components are assigned initial weights. The deviation between weight allocation and interaction intensity is minimized through iterative optimization. The error is measured by mean square error. The weights are adjusted using gradient descent until the error is less than a preset range. The optimized weight allocation result is multiplied with the modal features in the multimodal association feature space to generate weighted modal features. The value of each dimension of the weighted modal features is the product of the original feature value and the corresponding modal weight.
6. The method according to claim 5, characterized in that, The constructed interaction strength evaluation index system includes semantic consistency index, structural similarity index, and temporal correlation index. The semantic consistency index is calculated using cosine similarity, the structural similarity index is calculated using graph edit distance, and the temporal correlation index is calculated using event co-occurrence window analysis, including: The semantic dependencies of business rules and the dependencies of code execution paths are converted into semantic vector representations. The cosine value of the angle between the vectors is calculated by cosine similarity. The larger the value, the stronger the semantic relationship. The multimodal feature structure is represented as a directed graph. The number of insertion, deletion, and replacement operations required to transform one graph into another is calculated using the graph edit distance algorithm. The fewer the number of operations, the more similar the structures are. Co-occurrence windows are divided based on event timestamp information. The co-occurrence frequency of different modal features within the same time window is statistically analyzed. The ratio of the normalized co-occurrence frequency to the time window size is used as a temporal correlation index. By training with historical associated data, the fusion weights of semantic consistency index, structural similarity index, and temporal association index are determined, so as to maximize the correlation between the comprehensive evaluation results and the actual association strength. The calculation parameters of each indicator are automatically adjusted according to the type of multimodal features. For text modal features, the weight of semantic consistency is increased; for graphic modal features, the weight of structural similarity is increased; and for temporal modal features, the weight of temporal correlation is increased. Store the optimal combination of evaluation metrics for different types of multimodal feature pairs, and complete the selection of evaluation metrics through feature type matching.
7. The method according to claim 1, characterized in that, The dual-task collaborative training of test case generation and defect localization prediction on the unified joint representation vector adjusts the feature extraction weights of the two tasks through gradient backpropagation sharing between tasks, generating a test case generation parameter set, including: A dual-task network architecture is constructed, consisting of a shared feature extraction layer, a test case generation task layer, and a defect location prediction task layer. The shared feature extraction layer provides common features for the two tasks, the test case generation task layer outputs test case parameters, and the defect location prediction task layer outputs the probability of defect location. The unified joint representation vector is input into the shared feature extraction layer. Deep features are extracted through a hybrid structure of convolutional and recurrent layers. The convolutional layer captures local feature interactions, and the recurrent layer models temporal dependencies to generate a dual-task shared feature vector. The dual-task shared feature vector is input into the test case generation task layer. The sequence generation model generates the input parameter sequence, execution step sequence, and expected result sequence of the test cases. The edit distance loss between the generated sequence and the real test case sequence is calculated as the test case generation task loss. The dual-task shared feature vector is input into the defect localization prediction task layer. The defect probability distribution of the code module is predicted through the classification model. The cross-entropy loss between the predicted distribution and the actual defect location is calculated as the defect localization prediction task loss. The joint loss function is generated by weighted summing of the test case generation task loss and the defect localization prediction task loss. Backpropagation is performed based on the joint loss function to calculate the gradient of the loss with respect to the parameters of the shared feature extraction layer. This gradient is the weighted sum of the gradient of the test case generation task and the gradient of the defect localization prediction task. The weights are consistent with the dynamic weights of the two tasks. The parameters of the shared feature extraction layer are updated, and the feature extraction weights of the two tasks are adjusted synchronously. Iterative training is performed until the joint loss converges. The network parameters of the test case generation task layer are extracted as the test case generation parameter set.
8. The method according to claim 7, characterized in that, The backpropagation based on the joint loss function calculates the gradient of the loss with respect to the parameters of the shared feature extraction layer. This gradient is a weighted sum of the gradients of the test case generation task and the defect localization prediction task, with the weights consistent with the dynamic weights of the two tasks. The parameters of the shared feature extraction layer are updated using gradient descent, including: In each backpropagation process, the gradient of the test case generation task loss with respect to each parameter of the shared feature extraction layer is calculated and denoted as the first gradient. The gradient of the defect localization and prediction task loss with respect to each parameter of the shared feature extraction layer is calculated and denoted as the second gradient. Perform gradient consistency analysis on the first gradient and the second gradient, and calculate the gradient direction cosine similarity. The closer the direction cosine similarity value is to 1, the higher the degree of consistency of the gradient directions of the two tasks. The closer it is to -1, the higher the degree of conflict of gradient directions. When the gradient direction similarity is higher than the preset range, the first gradient and the second gradient are directly weighted and summed according to the dual-task dynamic weights to generate a shared gradient. When the similarity is below a preset range, the gradient projection method is used to project the conflicting gradients to a consistent direction, and then the weighted summation is used to generate a shared gradient. Gradient clipping is performed on the shared gradient to control the gradient norm within a preset range to avoid gradient explosion. The gradient direction is preserved during clipping, and only the gradient magnitude is adjusted. The momentum optimizer updates the parameters of the clipped shared gradient. The momentum term integrates the historical gradient direction, which accelerates convergence and suppresses oscillations. The learning rate dynamically decays with each training round.
9. The method according to claim 1, characterized in that, The step of inputting the test case generation parameter set into the generator of the adversarial generative network, and strengthening the feature representation of the boundary test scenario through feature adversarial learning with the discriminator to generate the boundary test case set includes: An adversarial generative network is constructed, which includes a generator and a discriminator. The generator uses a hybrid architecture of transposed convolution and recurrent network to generate test case features, and the discriminator uses a convolutional network architecture to distinguish between real and generated test cases. The input of both is the test case feature vector. The test case generation parameter set is concatenated with a random noise vector and used as the input to the generator. The generator gradually increases the feature dimension through a transposed convolutional layer and models the dependency relationship between test case steps through a loop layer, outputting the candidate boundary test case feature vector. Collect boundary test cases from the historical test case library, extract their feature vectors as real samples, and input them together with the feature vectors of candidate boundary test cases output by the generator into the discriminator. The discriminator performs multi-scale feature extraction on the input feature vectors and outputs the true and false probabilities through a fully connected layer. The expected probability of the real sample is the reference value one, and the expected probability of the generated sample is the reference value zero. The cross-entropy loss of the discriminator between real samples and generated samples is calculated and used as the discriminator loss. The discriminator parameters are updated through backpropagation to improve the ability to distinguish between real and fake samples. With the discriminator parameters fixed, the probability that a sample generated by the generator is judged as a real sample by the discriminator is calculated. The probability is positively correlated with the generator loss. At the same time, feature matching loss is introduced to calculate the distance between the generated sample and the real sample in the intermediate layer features of the discriminator. The total generator loss is the sum of the adversarial loss and the feature matching loss. Backpropagation is performed based on the generator's total loss to update the generator parameters. The discriminator update and generator update processes are performed iteratively. After each iteration, the boundary feature coverage of the generated samples is calculated. Training stops when the coverage reaches a preset range. The candidate boundary test case feature vectors output by the generator are converted into structured test case descriptions to generate a set of boundary test cases.
10. A computer system comprising a memory and a processor, the memory storing a computer program executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the method according to any one of claims 1 to 9.