Test case recommendation method based on knowledge graph attention network
By building a software test knowledge graph and using a knowledge graph attention network, the accuracy and applicability of use case recommendations in software testing are solved, and efficient test case generation and recommendations are achieved.
Patent Information
- Application Number
- CN202510484567.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-08-01
AI Technical Summary
The prior art fails to fully utilize the relationship between the use case ontology of professional fields and other knowledge ontology in software testing, resulting in insufficient recommendation accuracy and applicability. The traditional recommendation library cannot meet the rapidly increasing description requirements of the knowledge association relationship between the tested software projects.
Using the test case recommendation method based on the knowledge graph attention network, we use software to test the knowledge graph, use graph relationship information and collaborative filtering algorithms to integrate the interactive graph of user recommended use cases to realize the discovery of high-order relationship information and the rapid generation of test cases.
The accuracy and coverage of test case generation have been improved, and the accuracy of intelligent recommendations for automatic generation of test cases has reached 77.2%, and the recall rate has reached 77.9%, which is more than 10% higher than traditional methods.
Smart Images

Figure CN120407406A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of software testing technology, and specifically relates to a knowledge graph attention network recommendation technology. Background Art
[0002] In recent years, internet-based information technologies such as artificial intelligence and big data have rapidly developed and are gradually being applied to the testing field, providing new approaches to improving the quality and efficiency of software testing and verification. In the development of the internet and artificial intelligence, knowledge graphs, along with big data and deep learning, have become a core driving force. Knowledge graphs describe concepts, entities, and their relationships in the objective world in a structured manner, presenting various types of information in a form more closely aligned with human cognition, providing a better way to organize, manage, and understand massive amounts of information. Knowledge graphs have invigorated semantic search and are also demonstrating their power in intelligent question-answering, becoming the foundation for knowledge-driven intelligent applications. Building a software testing knowledge graph can help testers retrieve, access, and analyze various software testing information, uncovering potential relationships between test defects and test cases, and providing a foundation for research in intelligent technologies such as subsequent software test case recommendations.
[0003] Research on test case recommendation focuses on matching and retrieving test cases. Most existing studies improve the retrieval algorithms for recommended cases by constructing test case ontologies. These approaches focus solely on the reuse and retrieval of test cases, failing to fully consider the relationship between the domain-specific test case ontologies and other knowledge ontologies. This reduces their relevance and applicability to specific projects, hindering their effectiveness in practical engineering applications. Traditional software test case recommendation libraries often use relational databases as their underlying data storage. With the rapid increase in the number of software projects under test, traditional recommendation library design architectures are unable to clearly describe the knowledge relationships between these different projects.
[0004] Establishing a knowledge chain between test objects, test requirements, test types, and test cases can better mine potential information from test cases and enhance the accuracy of subsequent test case recommendations. This approach links isolated test cases in traditional test case libraries, improving recommendation accuracy.
[0005] In the implementation, unsupervised contrastive learning techniques are used to match Chinese text similarities between entities, combined with knowledge recommendation to establish a test case reuse recommendation model. Using a knowledge graph representation learning approach, semantic data is embedded into a low-dimensional semantic space, semantic similarities between use cases are calculated, and then integrated into a collaborative filtering recommendation algorithm.
[0006] The test case recommendation method based on knowledge graph has been applied in multiple fields, such as game automation testing, software testing, etc. By constructing a knowledge graph and defining test requirements and use case templates, test cases are automatically generated, improving test efficiency and coverage. This method helps the test team better understand the structure, relationships and behaviors of the system, and formulate test strategies and generate test cases more accurately. Summary of the Invention
[0007] To solve the technical problems that the collaborative filtering algorithm requires a large amount of cold-start user behavior data, and the deep recommendation model algorithm needs to independently model the features of training data, a technical solution of a test case recommendation method based on a knowledge graph attention network is adopted; by constructing and utilizing a knowledge graph, based on the knowledge graph attention network recommendation algorithm, co-attribute information is extracted from the user's behavior, and the graph relationship information and the interaction graph of the user's recommended use cases are fused into a graph space, combining the advantages of the collaborative filtering algorithm and the knowledge graph information to discover high-order relationship information. According to the constructed software test ontology relationship model, a software test knowledge graph is quickly constructed, and a software test knowledge matching method based on the fast similarity calculation of entity feature attributes and associated nodes is designed, and the knowledge graph attention network is used to carry out the application of software test case recommendation based on the knowledge graph; the technical effects of automatically generating test cases, optimizing the test case generation path, and improving the sufficiency and effectiveness of test case generation are produced. Without considering the relationship between user interaction data, the average accuracy of software intelligent test case recommendation is 77.2%, and the recall rate is 77.9%, which is more than 10% higher than the traditional semantic similarity matching recommendation method and the knowledge base-based software test case recommendation method.
[0008] Input the software requirements of the new project and the software test cases of the historical project, conduct research on the intelligent extraction technology of software test case keywords, construct a special noun dictionary in the software test field, and form a text segmentation set representing text features; perform unsupervised training and learning on the text data of the test case segmentation set and the software requirement segmentation set, generate word vectors that can represent keywords according to the position and quantity of each keyword in the test data text, and combine the word vectors of the keywords together to form a keyword vector set of each text data of requirements and use cases; adopt a knowledge graph attention network test case recommendation model and use the algorithm of knowledge entity collective alignment to achieve automation; with software requirement knowledge as the core, construct a knowledge sub-graph of the software requirements to be tested and their associated entities, and perform collective matching with each similar sub-graph in the software test knowledge graph network to obtain an optimized recommended output result and generate a new test case set; perform instantiation modification on the test cases of the output result to obtain the recommended test cases for this project.
[0009] Build a dictionary of specialized terms in the field of software testing, and implement professional data text word segmentation for software requirements and software test cases:
[0010] Step 1-1: Data preprocessing, cleaning, word segmentation, and part-of-speech tagging of the original data to generate a training data set;
[0011] Step 1-2: Feature extraction, extracting a set of features for each sample in the training data set, including word frequency, TF-IDF, and word vectors;
[0012] Step 1-3: Model training, inputting features and labels into the support vector machine (SVM) algorithm of the machine learning model for training to obtain a classifier;
[0013] Step 1-4: Entity extraction, using the classifier to classify new text data, extract useful knowledge information, and output the results.
[0014] According to the stop word dictionary and the professional vocabulary dictionary in the field of software testing, remove stop words and delete low-frequency words from the text, translate English abbreviation keywords, perform optimization training, and perform entity matching:
[0015] Step 2-1: Input semantic text, perform semantic keyword extraction and English abbreviation translation to obtain the Chinese keyword sequence S = {ω1, ω2, …, ω n} of this sentence. Use the training output file of the CBOW model to obtain the word vector value of each keyword, calculate the average of all word vector values in the sentence to obtain the sentence vector vec(S) of this semantic text, and perform entity matching:
[0016] Step 2-2: Given two entities u and v to be matched, both belonging to the same text attribute set A = {A1, A 2, …, A n}, calculate the cosine value between the sentence vectors S j and S u,j describing the text of the common attribute A v,j (1 ≤ j ≤ n) for u and v, to obtain the similarity sim j (u attr , v j ) of entities u and v on this attribute A[[ID=PR=V]] j );
[0017] Step 2-3: Since the influence degrees of the feature attribute values of different entities on the similarity calculation results are different, set different influence factors D j for the matching calculation results of each feature attribute, perform comprehensive weighted correction and averaging to obtain the comprehensive attribute similarity sim attr (u, v) of entities u and v;
[0018] Step 2-4: Calculate the entity similarity matrix, set a threshold, determine whether the entities are the same, merge similar entities into one entity, and output the entity fusion result.
[0019] According to the coverage traceability relationship between test cases and software requirements, retrieve the associated cases of software requirements similar to historical projects, and adopt the knowledge graph attention network recommendation algorithm to fuse the graph relationship information and the interaction graph of user-recommended cases into one graph space, synergize the advantages of the collaborative filtering algorithm and knowledge graph information, and realize test case recommendation based on requirement knowledge matching:
[0020] Step 3-1: Form a software requirement knowledge sub-graph G with the software requirement entity r of the project to be tested and its associated software under test, radar subsystem, and software development knowledge entity set;
[0021] Step 3-2: Partition the software test knowledge graph according to the domain and subsystem attribute key values of r, and extract the knowledge sub-graph G' to be matched;
[0022] Step 3-3: Assume there are N requirements and M test cases, and use a bipartite graph to represent the interaction between the two. Use V u to represent the set of requirement nodes, and use V i to represent the set of test case nodes, and obtain the node set V = V u ∪V i . Use u i to represent the embedding of the i-th requirement, and use v j to represent the embedding vector of the j-th test case, and obtain the corresponding embedding vector of each node;
[0023] [[ID=]]Step 3-4: Assume that in the k-th layer of the graph convolutional network, the representation vector of node i is Use to recursively update each node through the multi-layer attention embedding propagation layer;
[0024] Step 3-5: The knowledge graph attention network splices the embedding vector v j of the neighbor test case node j of each requirement node i and the embedding vector u i of the requirement node i together, and obtains an attention vector α i through a fully connected network f of one layer;
[0025] Step 3-6: The knowledge graph attention network weights and averages the representation vectors of the neighbor test case nodes j of each requirement node i according to the attention vector α i to obtain the final representation vector z i [[ID=]]of the requirement node i;
[0026] Step 3-7: Take z iRe - sort from largest to smallest and select the z with the largest similarity value. i As the software requirement matching result, use the test type and test case design method as the filtering conditions, and select the associated test cases as the output.
[0027] Step 3 - 8: Instantiate and modify the output test cases to obtain the recommended test cases for this project. Description of the Drawings
[0028] Figure 1 It is the test case recommendation method process based on the software test knowledge graph. Figure 2 It is the entity extraction process of the support vector machine based on TF - IDF. Figure 3 It is the knowledge matching process based on the CBOW model. Figure 4 It is the test case recommendation process based on requirement knowledge matching. Detailed Implementation Manner
[0029] The technical solution of the present invention will be specifically described below with reference to the drawings.
[0030] Construct a dictionary of specialized terms in the software testing field for word segmentation of professional data texts of software requirements and software test cases, such as Figure 1 shown as follows:
[0031] Step 1 - 1: Data pre - processing, clean, segment words, perform part - of - speech tagging, etc. on the original data to generate a training data set.
[0032] Step 1 - 2: Feature extraction, as Figure 2 shown, extract a set of features for each sample in the training data set, including word frequency, TF - IDF, and word vectors.
[0033] Let n i,j represent the number of times the term t i appears in the document d j , |D| represents the number of all documents, and |j:t i ∈d j | represents the number of documents containing the term t i , then
[0034] Step 1 - 3: Model training, input the features and labels into the machine learning model support vector machine SVM algorithm for training to obtain a classifier.
[0035] Step 1-4: Entity extraction. Use a classifier to classify the new text data, extract useful knowledge information, and output the results, including: [("radar", "NN"), ("is", "VC"), ("utilize", "W"), ("object", "NN"), ("reflect", "NN"), ("electromagnetic wave", "NN"), ("of", "DEG"), ("characteristic", "NN"), ("to", "MSP"), ("discover", "W")].
[0036] According to the stop word dictionary and the professional vocabulary dictionary in the software testing field, perform stop word removal and low-frequency word deletion on the text, translate the English abbreviation keywords, perform optimization training, and perform entity matching:
[0037] Step 2-1: Input the semantic text, perform semantic keyword extraction and English abbreviation translation to obtain the Chinese keyword sequence S = {ω1, ω2, …, ω n}, adopt the training output file of the CBOW model, as Figure 3 shown, obtain the word vector value of each keyword, and calculate the average of all word vector values in the sentence to obtain the sentence vector vec(S) of the semantic text;
[0038] Step 2-2: Given two entities u and v to be matched, both belonging to the same text attribute set A = {A1, A 2, …, A n}, calculate the cosine value between the sentence vectors S j and S u,j of the text described by the common attribute A v,j (1 ≤ j ≤ n) of u and v to obtain the similarity sim j (u attr , v j ) of entities u and v on the attribute A j , which is represented by the formula ;
[0039] Step 2-3: Since the influence degrees of the characteristic attribute values of different entities on the similarity calculation results are different, set different influence factors D j for the matching calculation results of each characteristic attribute, perform comprehensive weighted correction and averaging to obtain the comprehensive attribute similarity sim attr (u, v) of entities u and v, which is represented by the formula ;
[0040] Step 2-4: Calculate the entity similarity matrix, set a threshold, determine whether the entities are the same, merge the similar entities into one entity, and output the entity fusion result.
[0041] According to the coverage traceability relationship between test cases and software requirements, retrieve the associated cases of similar software requirements in historical projects. Adopt the knowledge graph attention network recommendation algorithm to fuse the graph relationship information and the interaction graph of user-recommended cases into one graph space, combining the advantages of the collaborative filtering algorithm and knowledge graph information, such as Figure 4 shown in the figure, to achieve test case recommendation based on demand knowledge matching:
[0042] Step 3-1: Form a software requirement knowledge sub-graph G with the software requirement entity r of the project to be tested and its associated software under test, radar subsystem, and software development knowledge entity set;
[0043] Step 3-2: Partition the software test knowledge graph according to the domain and subsystem attribute key values of r, and extract the knowledge sub-graph G' to be matched;
[0044] Step 3-3: Assume there are N requirements and M test cases, and use a bipartite graph to represent the interaction between them. Use V u to represent the set of requirement nodes, and use V i to represent the set of test case nodes, obtaining the node set V = V u ∪V i . Use u i to represent the embedding of the i-th requirement, and use v j to represent the embedding vector of the j-th test case, obtaining the corresponding embedding vector for each node;
[0045] Step 3-4: Assume that in the k-th layer of the graph convolutional network, the representation vector of node i is . Use to recursively update each node through the multi-layer attention embedding propagation layer, represented by the formula ;
[0046] Step 3-5: The knowledge graph attention network concatenates the embedding vector v j of the neighbor test case node j of each requirement node i and the embedding vector u i of the requirement node i, and obtains an attention vector α i through a fully connected network f, represented by the formula α i = softmax(f([u i ; v j , θ));
[0047] Step 3-6: The knowledge graph attention network performs weighted averaging on the representation vectors of the neighbor test case nodes j of each requirement node i according to the attention vector α i to obtain the final representation vector z i of the requirement node i, represented by the formula ;
[0048] Step 3-7: For z i Re-sort from largest to smallest, and select the z with the largest similarity value i As the software requirement matching result, use the test type and test case design method as filtering conditions, and select the associated test cases as the output;
[0049] Step 3-8: Make instantiation modifications to the output test cases to obtain the recommended test cases for this project.
[0050] The above are the embodiments of the present invention and do not limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included within the protection scope of the present invention.
Claims
1. A test case recommendation method based on a knowledge graph attention network, characterized in that, Including: Input new project software requirements and historical project software test cases, conduct research on intelligent extraction technology for software test case keywords, build a dictionary of specialized terms in the software testing field, and form a text segmentation set representing text features; perform unsupervised training and learning on the text data of the test case segmentation set and the software requirement segmentation set, generate word vectors that can represent keywords based on the positions and quantities of each keyword in the test data text, and combine the word vectors of the keywords to form a keyword vector set for each text data item of requirements and test cases; adopt a knowledge graph attention network test case recommendation model and use an algorithm for collective alignment of knowledge entities to achieve automation; with software requirement knowledge as the core, build a knowledge sub-graph of the software requirements to be tested and their associated entities, perform collective matching with each similar sub-graph in the software testing knowledge graph network, obtain an optimized recommended output result, and generate a new test case set; perform instantiation modification on the test cases of the output result to obtain the recommended test cases for this project.
2. The test case recommendation method based on the knowledge graph attention network according to claim 1, characterized in that As described above, it further includes: Step 1: Build a dictionary of specialized terms in the software testing field to achieve professional data text segmentation of software requirements and software test cases; Step 2: According to the stop word dictionary and the professional vocabulary dictionary in the software testing field, perform stop word removal and low-frequency word deletion processing on the text, translate English abbreviation keywords, perform optimization training, and perform entity matching; Step 3: According to the coverage traceability relationship between test cases and software requirements, retrieve the associated cases of similar software requirements in historical projects, adopt a knowledge graph attention network recommendation algorithm, fuse the graph relationship information and the interaction graph of user-recommended cases into a graph space, and combine the advantages of the collaborative filtering algorithm and the knowledge graph information to achieve test case recommendation based on requirement knowledge matching.
3. The test case recommendation method based on the knowledge graph attention network according to claim 1, wherein The said Step 1 includes: Step 1-1: Data preprocessing, cleaning, segmenting, and part-of-speech tagging the original data to generate a training data set; Step 1-2: Feature extraction, extracting a set of features for each sample in the training data set, including word frequency, TF-IDF, and word vectors; Step 1-3: Model training, inputting the features and labels into the machine learning model support vector machine (SVM) algorithm for training to obtain a classifier; Step 1-4: Entity extraction, using the classifier to classify new text data, extract useful knowledge information, and output the result.
4. The test case recommendation method based on the knowledge graph attention network according to claim 1, wherein Step 2 includes: Step 2-1: Input the semantic text, extract semantic keywords and translate English abbreviations to obtain the Chinese keyword sequence S = {ω1, ω2, …, ω n}, use the training output file of the CBOW model to obtain the word vector value of each keyword, calculate the average value of all word vector values in the sentence to obtain the sentence vector vec(S) of the semantic text, and perform entity matching; Step 2-2: Given two entities u and v to be matched, both belong to the same text attribute set A = {A1, A 2, …, A n}, calculate the cosine value between the sentence vectors S j (1 ≤ j ≤ n) describing the text of the common attribute A u,j and S v,j to obtain the similarity sim j (u attr , v j ) of entities u and v on the attribute A j ; Step 2-3: Since the influence degrees of the characteristic attribute value pairs of different entities on the similarity calculation results are different, different influence factors D are set for the matching calculation results of each characteristic attribute j , and comprehensive weighted correction and averaging are performed to obtain the comprehensive attribute similarity sim attr (u, v); Step 2-4: Calculate the entity similarity matrix, set a threshold, determine whether the entities are the same, merge similar entities into one entity, and output the entity fusion result.
5. The test case recommendation method based on the knowledge graph attention network according to claim 1, characterized in that Step 3 includes the following: Step 3-1: Form a software requirement knowledge sub-graph G with the software requirement entity r of the item to be tested, its related software under test, radar subsystem, and software development knowledge entity set; Step 3-2: Partition the software test knowledge graph according to the domain and subsystem attribute key values of r, and extract the knowledge sub-graph G to be matched ′ ; Step 3-3: Assume there are N requirements and M test cases, and use a bipartite graph to represent the interaction between them. Use V u to represent the set of requirement nodes, and use V i to represent the set of test case nodes, obtaining the node set V = V u ∪V i . Use u i to represent the embedding of the i-th requirement, and use v j to represent the embedding vector of the j-th test case, obtaining the corresponding embedding vectors of each node; Step 3-4: Assume that in the k-th layer graph convolutional network, the representation vector of node i is Use to recursively update each node through the multi-layer attention embedding propagation layer; Step 3-5: The knowledge graph attention network concatenates the embedding vector v j of the neighbor test case node j of each requirement node i and the embedding vector u i of the requirement node i, and obtains an attention vector α i through a fully connected network f; Step 3-6: The knowledge graph attention network weights and averages the representation vectors of the neighbor test case nodes j of each requirement node i according to the attention vector α i to obtain the final representation vector z i of the requirement node i; Step 3-7: Reorder z i from largest to smallest, and select the z i with the largest similarity value as the software requirement matching result. Use the test type and test case design method as screening conditions, and select the associated test cases as the output; Step 3-8: Instantiate and modify the output test cases to obtain the recommended test cases for this project
Citation Information
Cited By
Test method and test system for railway signal safety system software
CN121116837A