A regression test case recommendation method and device
By using word embedding models and feature fusion technology, the problem of insufficient regression test case recommendations for other systems during the upgrade and transformation of financial system software was solved, achieving efficient and accurate regression test case recommendations.
Patent Information
- Application Number
- CN202411716886.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-12-19
- Estimated Expiration
- 2044-11-27
AI Technical Summary
Existing technologies cannot effectively recommend regression test cases for financial system software upgrades and modifications on other related systems, resulting in low testing efficiency.
A word embedding model is used in combination with a bidirectional autoencoder and a bidirectional long short-term memory network. By calculating the correlation between the feature vectors of regression test cases and new transaction test cases, keywords and grammatical features are determined. After fusing the feature vectors, they are input into a classifier to determine the recommendation probability and perform deduplication to recommend the affected regression test cases.
It improves the accuracy and efficiency of regression testing, effectively identifies and recommends regression test cases for other related systems affected by new transactions, and reduces unnecessary duplication of work.
Smart Images

Figure CN119621567B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a regression test case recommendation method and device. BACKGROUND
[0002] Regression testing is a type of software testing, which aims to ensure that the original functions remain normal after system updates or modifications, and no new errors are introduced. However, financial software systems are large and complex, and it is difficult for testers to accurately assess the impact of each update on existing functions, resulting in the need for full regression testing of all functions, which consumes a large amount of time and resources. With the popularization of agile development mode, systems are frequently updated and new functions are added, and if full regression testing is performed after each change, the efficiency will be greatly reduced. Therefore, an intelligent recommendation mechanism is needed to select only the test cases related to the newly added or modified functions for regression testing, thereby improving testing efficiency and reducing unnecessary repetitive work.
[0003] In existing recommendation techniques, the text information corresponding to the test cases is preprocessed, the preprocessed text information is then subject to topic modeling to obtain a text feature vector, the categories of the test cases are then labeled, and then a SVM classification model is established based on the labeled test cases and the text feature vector. Finally, the feature vector corresponding to the test case to be classified is taken as the input of the SVM classification model to obtain the category of the test case, and the test case is recommended according to the category.
[0004] However, according to the classification results, only regression test cases belonging to the same theme or system as the newly added transaction can be recommended. However, the financial system software is complex, and the upgrade and modification of a theme system may also affect the functions of other theme systems, so in this case, the existing technology cannot recommend regression test cases of other related systems affected by the newly added transaction. SUMMARY
[0005] Based on the deficiencies of the existing technology, the present application provides a regression test case recommendation method and device to solve the problem that the existing technology cannot recommend regression test cases of other related systems affected by the newly added transaction.
[0006] To achieve the above purpose, the present application provides the following technical solutions:
[0007] The first aspect of the present application provides a regression test case recommendation method, comprising:
[0008] reading the newly added transaction test case input by the user and all regression test cases in the case library;
[0009] inputting the new transaction test case and all the regression test cases into a pre-trained word embedding model to obtain a feature vector corresponding to the new transaction test case and feature vectors corresponding to all the regression test cases; the word embedding model is composed of a bidirectional automatic encoder-decoder and a bidirectional long short-term memory network;
[0010] For each of the regression test cases, based on the feature vector corresponding to the new transaction test case and the feature vector corresponding to the regression test case, determine the keywords of the regression test case;
[0011] According to the keywords, determine the syntax features of the regression test case, and fuse the feature vector corresponding to the regression test case and the syntax features to obtain a fused feature;
[0012] inputting the fused feature into a pre-constructed classifier to obtain a recommended probability corresponding to the regression test case;
[0013] determine whether there are multiple target recommended probabilities greater than a preset threshold in all recommended probabilities;
[0014] If there are multiple target recommended probabilities greater than a preset threshold in all recommended probabilities, add the regression test cases corresponding to the multiple target recommended probabilities to a recommended result set;
[0015] de-duplicate the recommended result set to obtain a target recommended result set, and feed back the target recommended result set to the front end.
[0016] Optionally, in the regression test case recommendation method described above, the determination of the keywords of the regression test case based on the feature vector corresponding to the new transaction test case and the feature vector corresponding to the regression test case for each of the regression test cases comprises:
[0017] For each of the regression test cases, the attention mechanism is used to calculate the correlation coefficients between the multiple words corresponding to the regression test case and the feature vector corresponding to the new transaction test case, respectively;
[0018] select the maximum correlation coefficient from all correlation coefficients, and determine the word corresponding to the maximum correlation coefficient as the keyword of the regression test case.
[0019] Optionally, in the regression test case recommendation method described above, the determination of the syntax features of the regression test case according to the keywords comprises:
[0020] obtain the multiple words corresponding to the regression test case and the correlation coefficients between the multiple words and the feature vector corresponding to the new transaction test case.
[0021] constructing an adjacency matrix of the keywords based on the correlation coefficients and the keywords;
[0022] inputting a plurality of words corresponding to the regression test case into a Stanford grammar parser to obtain a syntax dependency tree of the regression test case;
[0023] sorting all the correlation coefficients in descending order, and extracting the top N correlation coefficients from the sorted correlation coefficients using a Top-K algorithm;
[0024] pruning the syntax dependency tree of the test case title based on the N correlation coefficients to obtain a target syntax dependency tree;
[0025] updating the adjacency matrix according to the target syntax dependency tree, and determining the updated adjacency matrix as the syntax feature of the regression test case.
[0026] Optionally, in the regression test case recommendation method described above, the step of fusing the feature vector corresponding to the regression test case and the syntax feature to obtain a fusion feature comprises:
[0027] inputting the feature vector corresponding to the regression test case into a semantic channel included in a graph convolution network for operation to obtain a semantic natural language feature vector corresponding to the regression test case;
[0028] inputting the feature vector corresponding to the regression test case and the syntax feature into a syntax channel included in the graph convolution network for operation to obtain a syntax natural language feature vector corresponding to the regression test case;
[0029] concatenating the semantic natural language feature vector and the syntax natural language feature vector according to feature dimensions to obtain a target feature vector, and encoding the target feature vector to obtain the fusion feature.
[0030] Optionally, in the regression test case recommendation method described above, the step of performing deduplication processing on the recommendation result set to obtain a target recommendation result set comprises:
[0031] determining, according to the number of each regression test case in the recommendation result set, whether there is a same regression test case in the recommendation result set;
[0032] if there is a same regression test case in the recommendation result set, extracting all the same regression test cases from the recommendation result set, and dividing all the same regression test cases according to the number to obtain a plurality of regression test case sets;
[0033] extracting any one of the regression test cases from each of the regression test case set to add to the recommended result set, to obtain a target recommended result set.
[0034] The second aspect of the application provides a regression test case recommendation device, comprising:
[0035] A reading unit is configured to read an added transaction test case input by a user and all regression test cases in a case library.
[0036] A case input unit is configured to input the added transaction test case and all the regression test cases into a pre-trained word embedding model to obtain a feature vector corresponding to the added transaction test case and a feature vector corresponding to all the regression test cases, wherein the word embedding model is composed of a bidirectional automatic encoder-decoder and a bidirectional long short-term memory network.
[0037] A keyword determination unit is configured to determine a keyword of each of the regression test cases based on the feature vector corresponding to the added transaction test case and the feature vector corresponding to the regression test case.
[0038] A syntax feature determination unit is configured to determine a syntax feature of the regression test case according to the keyword, and fuse the feature vector corresponding to the regression test case and the syntax feature to obtain a fused feature.
[0039] A feature input unit is configured to input the fused feature into a pre-built classifier to obtain a recommended probability corresponding to the regression test case.
[0040] A probability judgment unit is configured to determine whether there are multiple target recommended probabilities greater than a preset threshold in all recommended probabilities.
[0041] A case addition unit is configured to add the regression test cases corresponding to the multiple target recommended probabilities greater than the preset threshold to a recommended result set if there are multiple target recommended probabilities greater than a preset threshold in all recommended probabilities.
[0042] A de-duplication processing unit is configured to perform de-duplication processing on the recommended result set to obtain a target recommended result set, and feed back the target recommended result set to a front end.
[0043] Optionally, in the regression test case recommendation device, the keyword determination unit comprises:
[0044] A calculation unit is configured to calculate a correlation coefficient between a plurality of words corresponding to the regression test case and the feature vector corresponding to the added transaction test case for each of the regression test cases by using an attention mechanism.
[0045] The keyword sub-determining unit is configured to filter out a maximum correlation coefficient from all the correlation coefficients, and determine a word corresponding to the maximum correlation coefficient as a keyword of the regression test case.
[0046] Optionally, in the regression test case recommendation device, the syntax feature determining unit comprises:
[0047] The obtaining unit is configured to obtain correlation coefficients between a plurality of words corresponding to the regression test case and a feature vector corresponding to the newly added transaction test case;
[0048] The constructing unit is configured to construct an adjacency matrix of the keyword based on the correlation coefficients and the keyword;
[0049] The first input unit is configured to input the plurality of words corresponding to the regression test case into a Stanford syntax parser to obtain a syntax dependency tree of the regression test case;
[0050] The sorting unit is configured to sort all the correlation coefficients in descending order, and extract the top N correlation coefficients from the sorted correlation coefficients by using a Top-K algorithm;
[0051] The pruning processing unit is configured to perform pruning processing on the syntax dependency tree of the test case title based on the N correlation coefficients to obtain a target syntax dependency tree;
[0052] The syntax feature sub-determining unit is configured to update the adjacency matrix according to the target syntax dependency tree, and determine the updated adjacency matrix as a syntax feature of the regression test case.
[0053] Optionally, in the regression test case recommendation device, the syntax feature determining unit comprises:
[0054] The second input unit is configured to input the feature vector corresponding to the regression test case into a semantic channel included in a graph convolution network to perform operation, and obtain a semantic natural language feature vector corresponding to the regression test case;
[0055] The third input unit is configured to input the feature vector corresponding to the regression test case and the syntax feature into a syntax channel included in the graph convolution network to perform operation, and obtain a syntax natural language feature vector corresponding to the regression test case;
[0056] The encoding processing unit is configured to perform concatenation processing on the semantic natural language feature vector and the syntax natural language feature vector in a feature dimension to obtain a target feature vector, and perform encoding processing on the target feature vector to obtain a fusion feature.
[0057] Optionally, in the recommendation device for regression test cases described above, the deduplication processing unit comprises:
[0058] a judgment unit configured to determine, according to the number of each regression test case in the recommendation result set, whether there is a same regression test case in the recommendation result set;
[0059] an extraction unit configured to, if there is a same regression test case in the recommendation result set, extract all the same regression test cases from the recommendation result set, and divide all the same regression test cases according to the number to obtain a plurality of regression test case sets;
[0060] an adding subunit configured to add any one of the regression test cases from each of the regression test case sets to the recommendation result set respectively to obtain a target recommendation result set.
[0061] The method for recommending regression test cases provided by the present application comprises the following steps: reading an input new transaction test case input by a user and all regression test cases in a case library; inputting the new transaction test case and all the regression test cases into a pre-trained word embedding model to obtain a feature vector corresponding to the new transaction test case and a feature vector corresponding to all the regression test cases; determining a keyword of each regression test case based on the feature vector corresponding to the new transaction test case and the feature vector corresponding to the regression test case; determining a syntax feature of the regression test case according to the keyword; fusing the feature vector corresponding to the regression test case and the syntax feature to obtain a fused feature; inputting the fused feature into a pre-constructed classifier to obtain a recommendation probability corresponding to the regression test case; determining whether there are multiple target recommendation probabilities greater than a preset threshold in all the recommendation probabilities; if there are multiple target recommendation probabilities greater than the preset threshold in all the recommendation probabilities, adding the regression test cases corresponding to the multiple target recommendation probabilities to a recommendation result set; performing deduplication processing on the recommendation result set to obtain a target recommendation result set; and feeding back the target recommendation result set to a front end. Thus, the natural language features of the regression test cases are directly used to determine the semantic similarity between each regression test case and the input new transaction test case title, i.e., the recommendation probability, and the regression test cases are added to the recommendation result set according to the recommendation probability, thereby effectively solving the problem that the regression test cases of other related systems affected by the new transaction cannot be recommended. BRIEF DESCRIPTION OF DRAWINGS
[0062] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the accompanying drawings needed to be used in the description of the embodiments or the prior art will be briefly introduced. Obviously, the accompanying drawings in the following description only represent some embodiments of the present application, and for those skilled in the field, other drawings can be obtained without creative effort based on the provided drawings.
[0063] Figure 1 A flow chart of a regression test case recommendation method provided by an embodiment of the present application;
[0064] Figure 2 A flow chart of a keyword determination method provided by an embodiment of the present application;
[0065] Figure 3 A flow chart of a syntax feature determination method provided by an embodiment of the present application;
[0066] Figure 4 A flow chart of a fusion feature fusion method provided by an embodiment of the present application;
[0067] Figure 5 A flow chart of a duplicate removal method of a recommendation result set provided by an embodiment of the present application;
[0068] Figure 6 A structural schematic diagram of a regression test case recommendation device provided by another embodiment of the present application. DETAILED DESCRIPTION
[0069] The technical solutions in the embodiments of the present application will be described clearly and completely below with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments only represent some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative effort fall within the scope of the present application.
[0070] In the present application, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or equipment including the element.
[0071] The embodiment of the present application provides a regression test case recommendation method, as shown in the method, and the method specifically comprises the following steps. Figure 1
[0072] S101, reading an added transaction test case input by a user and all regression test cases in a case library.
[0073] It can be understood that, in order to find regression test cases affected by the added transaction for recommendation, optionally, a tester can send the added transaction test case through an input interface provided by the system, and obtain all regression test cases from the case library, so as to find the regression test cases affected by the added transaction test case.
[0074] S102, inputting the added transaction test case and all regression test cases into a pre-trained word embedding model to obtain a feature vector corresponding to the added transaction test case and a feature vector corresponding to all regression test cases.
[0075] The word embedding model is composed of a bidirectional automatic encoding and decoding device and a bidirectional long short-term memory network.
[0076] Specifically, the added transaction test case input by the tester is parsed, that is, the title contained in the added transaction test case is read Wherein, represents the word embedding vector of the i-th word in the title contained in the added transaction test case, then each word embedding vector is taken as the input of a bidirectional automatic encoding and decoding device (Bidirectional Encoder Representation from Transformers, BERT), then the word embedding feature vector corresponding to each word output by BERT The feature vector of the title of the added transaction test case is obtained by summing and averaging the feature vectors of the words in the title through the bidirectional long short-term memory network. That is, represents the semantic feature of the title of the added transaction test case, wherein n is the length of the added transaction test case.
[0077] Next, the title contained in each regression test case in the case library is read, and each word in the title is input into BERT to obtain the word embedding feature vector of each word in the title contained in all regression test cases That is, the feature vector corresponding to all regression test cases.
[0078] S103, for each regression test case, determining the keyword of the regression test case based on the feature vector corresponding to the added transaction test case and the feature vector corresponding to the regression test case.
[0079] It should be noted that, in order to know the relevance between the newly added transaction test case and each regression test case, the similarity or correlation between the regression test case and the feature vector of the newly added transaction test case is calculated, so as to help extract and identify the most critical part of the regression test case, and then it can be effectively judged which part of the regression test case needs to be paid attention to and optimized, thereby improving the test efficiency and accuracy.
[0080] Optionally, in another embodiment of the present application, a specific implementation of step S103 includes the following steps: Figure 2
[0081] S201, for each regression test case, the attention mechanism is used to calculate the correlation coefficient between the plurality of words corresponding to the regression test case and the feature vector corresponding to the newly added transaction test case.
[0082] Specifically, the plurality of words corresponding to the regression test case and the feature vector corresponding to the newly added transaction test case are calculated by vector inner product, and the vector inner product calculation result corresponding to each word in the title contained in the regression test case is recorded. Then, the exponential function is used to normalize the vector inner product calculation result of each word, that is Thus, the semantic correlation coefficient Lambda={λ1,λ2,...,λ n} between each word in the title contained in the regression test case and the feature vector of the newly added transaction test case can be obtained, and λn is a coefficient between 0 and 1.
[0083] S202, the maximum correlation coefficient is selected from all correlation coefficients, and the word corresponding to the maximum correlation coefficient is determined as the keyword of the regression test case.
[0084] It can be understood that after obtaining all correlation coefficients, all semantic correlation coefficients Lambda={λ1,λ2,...,λ n} can be sorted in descending order or ascending order of the coefficients, so as to flexibly and effectively select the maximum correlation coefficient from the sorted correlation coefficients, and then the word corresponding to the maximum correlation coefficient is taken as the keyword of the regression test case, that is, the keyword of the title contained in the regression test case, and the word embedding vector corresponding to the keyword is obtained.
[0085] S104, according to the keyword, the syntax feature of the regression test case is determined, and the feature vector and the syntax feature corresponding to the regression test case are fused to obtain the fusion feature.
[0086] Specifically, in order to better understand the structure and logic of the test case, thereby improving the effect of regression testing, to more accurately recommend the regression test cases affected by the newly added transaction test case, and to more accurately describe the overall structure and functional requirements of the test case, thereby improving the effect, efficiency and intelligent level of regression testing, and thus effectively helping the present application to solve the problem of not being able to recommend the regression test cases of other related systems affected by the newly added transaction.
[0087] Optionally, in another embodiment of the present application, a specific implementation of determining the syntactic features of the regression test case according to the keywords in step S104 includes the following steps: Figure 3
[0088] S301, obtaining the correlation coefficients between the plurality of words corresponding to the regression test case and the feature vectors corresponding to the newly added transaction test case.
[0089] S302, constructing an adjacency matrix of the keywords based on the correlation coefficients and the keywords.
[0090] It can be understood that, in order to represent the relationship strength and mutual dependency between the keywords and the words, therefore, the adjacency matrix of the keywords can be constructed based on the correlation coefficients and the keywords, for example, if the keywords have an adjacency relationship with a certain word in the title (i.e. there is a dependency relationship in the syntax dependency tree), it is marked as a non-zero value in the adjacency matrix, indicating that there is a relationship between them.
[0091] S303, inputting the plurality of words corresponding to the regression test case into the Stanford syntax parser to obtain the syntax dependency tree of the regression test case.
[0092] It should be noted that, in order to clearly represent the dependency relationship between each word in the title, therefore, in the embodiment of the present application, the plurality of words corresponding to the regression test case are input into the Stanford syntax parser to obtain the syntax dependency tree T=(V, A, R) of the regression test case, so that the syntax dependency tree represents the syntactic features of the title sentence contained in the regression test case, wherein V represents a set of syntax dependency tree nodes, each node in the set of syntax dependency tree nodes represents a word embedding vector of each word in the title of the regression test case There are i nodes in total, and A represents the adjacency matrix between the word nodes of the syntax dependency tree.
[0093] For example, when the keyword i has an adjacency relationship with a certain word j in the title of the regression test case, i.e. A ij =1, let R ij =r ij represent the dependency relation between the nodes provided by the parser, such as nominal subject (nsubj), clausal complement (ccomp), etc., while when A ij = 0, then R ij = None, representing no adjacency relation between the keyword i and a certain word j in the use case title, and then embedding the syntactic dependency relation between the word nodes in the dependency tree into the adjacency matrix of the keyword.
[0094] S304, sort all the correlation coefficients in descending order, and extract the top N correlation coefficients from the sorted correlation coefficients using the Top-K algorithm.
[0095] It should be noted that, considering that the syntactic information provided by the Stanford parser may have errors, in order to accurately recommend regression test cases subsequently, the Top-K algorithm can be used to prune the syntactic dependency tree T of the test case title, that is, first arrange Lambda = {λ1, λ2,..., λ n} in descending order, then set the threshold of Top-K to 3, or the threshold of Top-K can be set according to the actual situation, and after setting the threshold of Top-K, extract the top 3 correlation coefficients from the sorted correlation coefficients.
[0096] S305, based on the N correlation coefficients, prune the syntactic dependency tree of the test case title to obtain a target syntactic dependency tree.
[0097] It can be understood that after selecting the correlation coefficients, the N correlation coefficients can be used as the adjacency relation between the word nodes and the keywords, that is, the syntactic dependency tree is pruned, that is, only the adjacency relation of the N correlation coefficients is retained in the syntactic dependency tree, and the adjacency relation of other word nodes can be deleted, thereby obtaining the target syntactic dependency tree.
[0098] S306, update the adjacency matrix according to the target syntactic dependency tree, and determine the updated adjacency matrix as the syntactic feature of the regression test case.
[0099] Specifically, when the target syntactic dependency tree is obtained, the adjacency matrix can be updated according to the adjacency relation in the target syntactic dependency tree, that is, the value corresponding to the adjacency relation in the adjacency matrix is set to the corresponding correlation coefficient A ij = λ j , the relation between the nodes is R ij = r ij , and the values corresponding to other nodes in the adjacency matrix are set to A ij= 0, the relationship between nodes is recorded as R ij = None.
[0100] Optionally, in another embodiment of the present application, the feature vector corresponding to the regression test case and the syntax feature are fused in step S104 to obtain a specific implementation of the fused feature, as shown in the following steps: Figure 4
[0101] S401, input the feature vector corresponding to the regression test case into the semantic channel included in the graph convolution network for operation to obtain the semantic natural language feature vector corresponding to the regression test case.
[0102] Specifically, the semantic channel in the graph convolution network can be constructed, that is, the word embedding vectors corresponding to the plurality of words in the regression test case are input into the semantic channel included in the graph convolution network for operation, and the iteratively updated semantic natural language feature vector corresponding to the regression test case is output, that is:
[0103]
[0104] Wherein, D(i) represents a set of words in the regression test case having an adjacency relationship with the keyword i in the syntax dependency tree, and A ij is the semantic correlation coefficient calculated by the attention mechanism jj , W1 is a trainable parameter matrix of the semantic channel of the graph convolution network, which can be iteratively updated by the gradient descent algorithm.
[0105] S402, input the feature vector corresponding to the regression test case and the syntax feature into the syntax channel included in the graph convolution network for operation to obtain the syntax natural language feature vector corresponding to the regression test case.
[0106] It can be understood that the syntax natural language feature vector can be obtained by constructing the syntax channel in the graph convolution network, specifically, the feature vector corresponding to the regression test case and the syntax feature, that is, the adjacency syntax relationship r ij between the keyword i and the context word j in the regression test case, are input into the syntax channel included in the graph convolution network for operation, and the iteratively updated syntax natural language feature vector corresponding to the regression test case is output, that is:
[0107]
[0108] Wherein, D(i) represents a set of words in the regression test case having an adjacency relationship with the keyword i in the syntax dependency tree, and β ij represent the weight coefficients calculated from the syntactic dependency relations between the keyword nodes and other words in the regression test case title, specifically, β ij The expression of β is:
[0109]
[0110] wherein the coefficient is a feature vector directly mapped by the dependency relation, W r1 and W r2 are the trainable parameter matrices of the syntactic channel of the graph convolution network, and are the trainable parameter vectors of the syntactic channel of the graph convolution network, and can be fine-tuned at each model iteration through a gradient descent algorithm, and σ and relu are the nonlinear activation functions of the neural network.
[0111] S403, according to the feature dimension, the semantic natural language feature vector and the syntactic natural language feature vector are concatenated to obtain a target feature vector, and the target feature vector is encoded to obtain a fusion feature.
[0112] It can be understood that after obtaining the semantic natural language feature vector and the syntactic natural language feature vector, the semantic natural language feature vector and the syntactic natural language feature vector need to be fused, so as to better understand the surface structure of the regression case, and also can deeply grasp the deep semantic, so as to more accurately recommend the regression test case affected by the newly added transaction test case. Specifically, the semantic natural language feature vector and the syntactic natural language feature vector are spliced according to the feature dimension of the semantic natural language feature vector and the syntactic natural language feature vector to obtain a target feature vector, and the target feature vector is encoded in parallel, so that the fusion feature can be obtained, that is, the expression of the fusion feature is: wherein W is a trainable parameter matrix, is a trainable parameter vector, and can be fine-tuned at each model iteration through a gradient descent algorithm, and relu is a nonlinear activation function of the neural network, and || represents the concatenation operation of the vector.
[0113] S105, input the fusion feature into the pre-constructed classifier to obtain the recommendation probability corresponding to the regression test case.
[0114] It should be emphasized that after obtaining the fusion feature, the fusion feature can be input into the classifier with a fully connected neural network, and then the network parameters of the classifier are updated using a gradient descent algorithm, and the recommendation probability corresponding to the regression test case is output wherein W p is a trainable parameter matrix, are trainable parameter vectors, each of which can be fine-tuned at each model iteration by a gradient descent algorithm, and softmax is a nonlinear activation function of the neural network.
[0115] S106, judge whether there are multiple target recommendation probabilities greater than the preset threshold in all recommendation probabilities.
[0116] It can be understood that after obtaining the recommendation probability of all regression test cases, considering that not all regression test cases are suitable for recommending to testers, a threshold can be set to exclude regression test cases, so that accurate regression test cases can be recommended, that is, whether there are multiple target recommendation probabilities greater than the preset threshold in all recommendation probabilities. If there are multiple target recommendation probabilities greater than the preset threshold in all recommendation probabilities, it means that only these target recommendation probabilities meet the recommendation condition, so step S107 is executed.
[0117] Alternatively, if there are multiple target recommendation probabilities not greater than the preset threshold in all recommendation probabilities, it means that there is no regression test case that meets the recommendation condition in all regression test cases. At this time, the front-end tester can be fed back to check whether there is an error operation in time.
[0118] Alternatively, the preset threshold is 0.5, but it can also be other thresholds, which are set according to actual conditions.
[0119] S107, add the regression test cases corresponding to the multiple target recommendation probabilities to the recommendation result set.
[0120] Specifically, when there are multiple target recommendation probabilities greater than the preset threshold in all recommendation probabilities, the regression test cases corresponding to the multiple target recommendation probabilities are integrated to obtain the recommendation result set.
[0121] S108, de-duplicate the recommendation result set to obtain a target recommendation result set, and feed back the target recommendation result set to the front end.
[0122] It can be understood that in order to reduce information redundancy and make each regression test case in the recommendation result set more valuable, the recommendation result set is de-duplicated before being fed back to the front end.
[0123] Alternatively, in another embodiment of the present application, a specific implementation of de-duplicating the recommendation result set in step S108 to obtain the target recommendation result set, as shown in Figure 5 includes the following steps:
[0124] S501, according to the number of each regression test case in the recommendation result set, judge whether there is a same regression test case in the recommendation result set.
[0125] Specifically, the number of each regression test case is unique, so the recommended result set can be de-duplicated by the number, that is, whether the same regression test case exists in the recommended result set is determined according to the number of each regression test case in the recommended result set. If the same regression test case exists in the recommended result set, it means that the recommended result set has information redundancy, so step S502 is executed at this time.
[0126] Alternatively, if the same regression test case does not exist in the recommended result set, it means that each regression test case in the recommended result set is more valuable, so the recommended result set can be directly fed back to the tester.
[0127] S502, extract all the same regression test cases from the recommended result set, and divide all the same regression test cases according to the number to obtain multiple regression test case sets.
[0128] Specifically, when the same regression test case exists in the recommended result set, all the same regression test cases need to be selected from the recommended result set. In order to know which regression test cases are the same, the selected regression test cases can be divided by the number of the regression test cases, thereby obtaining multiple regression test case sets, wherein each regression test case set contains the same regression test cases.
[0129] S503, extract any one regression test case from each regression test case set and add it to the recommended result set to obtain a target recommended result set.
[0130] Specifically, after obtaining the regression test case set, only one regression test case in the regression test case set can be retained, and the other regression test cases can be deleted, and then the retained regression test case is added back to the recommended result set and fed back to the front end.
[0131] Alternatively, one same regression test case can be directly retained in the recommended result set, and another same regression test case can be deleted.
[0132] The application provides a regression test case recommendation method, which comprises the following steps: reading an input new transaction test case and all regression test cases in a case library; inputting the new transaction test case and all regression test cases into a pre-trained BERT to obtain a feature vector corresponding to the new transaction test case and a feature vector corresponding to all regression test cases; determining a keyword of each regression test case based on the feature vector corresponding to the new transaction test case and the feature vector corresponding to the regression test case; determining a syntax feature of the regression test case according to the keyword, and fusing the feature vector corresponding to the regression test case and the syntax feature to obtain a fusion feature; inputting the fusion feature into a pre-constructed classifier to obtain a recommendation probability corresponding to the regression test case; determining whether there are multiple target recommendation probabilities greater than a preset threshold in all recommendation probabilities; if there are multiple target recommendation probabilities greater than the preset threshold in all recommendation probabilities, adding the regression test cases corresponding to the multiple target recommendation probabilities to a recommendation result set; and performing a de-duplication processing on the recommendation result set to obtain a target recommendation result set, and feeding back the target recommendation result set to a front end. Thus, the semantic similarity between each regression test case and the input new transaction test case title, that is, the recommendation probability, is directly determined by using the natural language features of the regression test case, and the regression test cases of other related systems affected by the new transaction are effectively recommended.
[0133] Another embodiment of the application provides a regression test case recommendation device, as shown in the accompanying drawings, comprising the following units: Figure 6
[0134] The reading unit 601 is configured to read an input new transaction test case and all regression test cases in a case library.
[0135] The case input unit 602 is configured to input the new transaction test case and all regression test cases into a pre-trained word embedding model to obtain a feature vector corresponding to the new transaction test case and a feature vector corresponding to all regression test cases. The word embedding model is composed of a bidirectional automatic encoder-decoder and a bidirectional long short-term memory network.
[0136] The keyword determination unit 603 is configured to determine a keyword of each regression test case based on the feature vector corresponding to the new transaction test case and the feature vector corresponding to the regression test case.
[0137] The syntax feature determination unit 604 is configured to determine a syntax feature of the regression test case according to the keyword, and fuse the feature vector corresponding to the regression test case and the syntax feature to obtain a fusion feature.
[0138] The feature input unit 605 is configured to input the fused features into a pre-constructed classifier to obtain a recommended probability corresponding to the regression test case.
[0139] The probability judgment unit 606 is configured to judge whether there are multiple target recommended probabilities greater than a preset threshold in all recommended probabilities.
[0140] The use case adding unit 607 is configured to add, if there are multiple target recommended probabilities greater than the preset threshold in all recommended probabilities, regression test cases corresponding to the multiple target recommended probabilities to a recommended result set.
[0141] The de-duplication processing unit 608 is configured to perform de-duplication processing on the recommended result set to obtain a target recommended result set, and feed back the target recommended result set to a front end.
[0142] It should be noted that the specific working processes of the above units in the embodiments of the present application can be correspondingly referred to steps S101-S108 in the above method embodiments, which will not be described here.
[0143] Optionally, another embodiment of the present application provides a regression test case recommendation device, wherein the keyword determining unit 603 comprises:
[0144] The computing unit is configured to respectively calculate, for each regression test case, correlation coefficients between multiple words corresponding to the regression test case and a feature vector corresponding to the new transaction test case by using an attention mechanism.
[0145] The keyword sub-determining unit is configured to filter out a maximum correlation coefficient from all correlation coefficients, and determine a word corresponding to the maximum correlation coefficient as a keyword of the regression test case.
[0146] Optionally, another embodiment of the present application provides a regression test case recommendation device, wherein the syntax feature determining unit 604 comprises:
[0147] The obtaining unit is configured to obtain multiple words corresponding to the regression test case and correlation coefficients between the multiple words and a feature vector corresponding to the new transaction test case.
[0148] The constructing unit is configured to construct an adjacency matrix of the keyword based on the correlation coefficients and the keyword.
[0149] The first input unit is configured to input the multiple words corresponding to the regression test case into a Stanford syntax parser to obtain a syntax dependency tree of the regression test case.
[0150] The sorting unit is configured to sort all the correlation coefficients in descending order, and extract the top N correlation coefficients from the sorted correlation coefficients by using a Top-K algorithm.
[0151] The pruning processing unit is configured to prune the syntax dependency tree of the test case title based on the N correlation coefficients, and obtain a target syntax dependency tree.
[0152] The syntax feature sub-determining unit is configured to update the adjacency matrix according to the target syntax dependency tree, and determine the updated adjacency matrix as the syntax feature of the regression test case.
[0153] Optionally, another embodiment of the application provides a regression test case recommendation device, and the syntax feature determining unit 604 includes:
[0154] The second input unit is configured to input the feature vector corresponding to the regression test case into a semantic channel included in the graph convolution network for operation, and obtain a semantic natural language feature vector corresponding to the regression test case.
[0155] The third input unit is configured to input the feature vector corresponding to the regression test case and the syntax feature into a syntax channel included in the graph convolution network for operation, and obtain a syntax natural language feature vector corresponding to the regression test case.
[0156] The encoding processing unit is configured to perform cascade processing on the semantic natural language feature vector and the syntax natural language feature vector according to the feature dimension, obtain a target feature vector, and perform encoding processing on the target feature vector to obtain a fusion feature.
[0157] Optionally, another embodiment of the application provides a regression test case recommendation device, and the deduplication processing unit 608 includes:
[0158] The determining unit is configured to determine whether there is a same regression test case in the recommendation result set according to the number of each regression test case in the recommendation result set.
[0159] The extracting unit is configured to extract all the same regression test cases from the recommendation result set if there is a same regression test case in the recommendation result set, and divide all the same regression test cases according to the number to obtain a plurality of regression test case sets.
[0160] The adding sub-unit is configured to add any one regression test case from each regression test case set to the recommendation result set respectively to obtain a target recommendation result set.
[0161] It should be noted that the specific working processes of each unit provided in the above embodiments of the application can be correspondingly referred to the corresponding steps in the above method embodiments, which will not be described here.
[0162] It should be further noted that the regression test case recommendation device provided by the embodiments of the present application has the technical effects of any one of the above embodiments, and the embodiments of the present application will not be repeated here.
[0163] Those skilled in the art will further appreciate that the units and algorithm steps of the examples described in connection with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms above as being generally described in the above description. Whether such functionality is implemented in hardware or software depends on the particular application and design constraints imposed on the overall system. Those skilled in the art can implement the described functionality in varying ways for each particular application, but such implementation should not be interpreted as a departure from the scope of the present application.
[0164] The above description of the disclosed embodiments enables a person skilled in the art to implement or use the present application. Various modifications to the embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for recommending regression test cases, characterized in that, The method comprises the following steps: reading a newly added transaction test case input by a user and all regression test cases in a case library; inputting the newly added transaction test case and all the regression test cases into a pre-trained word embedding model to obtain a feature vector corresponding to the newly added transaction test case and a feature vector corresponding to all the regression test cases; wherein the word embedding model is composed of a bidirectional automatic encoder-decoder and a bidirectional long short-term memory network; for each regression test case, determining a keyword of the regression test case based on the feature vector corresponding to the newly added transaction test case and the feature vector corresponding to the regression test case; determining a syntax feature of the regression test case according to the keyword, and fusing the feature vector corresponding to the regression test case and the syntax feature to obtain a fused feature; inputting the fused feature into a pre-constructed classifier to obtain a recommended probability corresponding to the regression test case; determining whether there are multiple target recommended probabilities greater than a preset threshold in all recommended probabilities; if there are multiple target recommended probabilities greater than a preset threshold in all recommended probabilities, adding the regression test cases corresponding to the multiple target recommended probabilities to a recommended result set; performing a deduplication process on the recommended result set to obtain a target recommended result set, and feeding back the target recommended result set to a front end.
2. The method of claim 1, wherein, The step of determining the keyword of the regression test case based on the feature vector corresponding to the newly added transaction test case and the feature vector corresponding to the regression test case comprises the following steps: for each regression test case, calculating a correlation coefficient between a plurality of words corresponding to the regression test case and the feature vector corresponding to the newly added transaction test case by using an attention mechanism; selecting a maximum correlation coefficient from all correlation coefficients, and determining a word corresponding to the maximum correlation coefficient as the keyword of the regression test case.
3. The method of claim 1, wherein, The step of determining the syntax feature of the regression test case according to the keyword comprises the following steps: obtaining a plurality of words corresponding to the regression test case and a correlation coefficient between the plurality of words and the feature vector corresponding to the newly added transaction test case; constructing an adjacency matrix of the keyword based on the correlation coefficient and the keyword; inputting the plurality of words corresponding to the regression test case into a Stanford syntax parser to obtain a syntax dependency tree of the regression test case; sorting all correlation coefficients in descending order, and extracting the first N correlation coefficients from the sorted correlation coefficients by using a Top-K algorithm; pruning the syntax dependency tree of the test case title based on the N correlation coefficients to obtain a target syntax dependency tree; updating the adjacency matrix according to the target syntax dependency tree, and determining the updated adjacency matrix as the syntax feature of the regression test case.
4. The method of claim 1, wherein, The step of fusing the feature vector corresponding to the regression test case and the syntax feature to obtain a fused feature comprises the following steps: input the feature vector corresponding to the regression test case into a semantic channel included in the graph convolution network for operation to obtain a semantic natural language feature vector corresponding to the regression test case; input the feature vector corresponding to the regression test case and the syntax feature into a syntax channel included in the graph convolution network for operation to obtain a syntax natural language feature vector corresponding to the regression test case; concatenate the semantic natural language feature vector and the syntax natural language feature vector according to a feature dimension to obtain a target feature vector, and encode the target feature vector to obtain a fusion feature.
5. The method of claim 1, wherein, The de-duplication processing on the recommendation result set to obtain a target recommendation result set comprises: determining, according to the number of each regression test case in the recommendation result set, whether there is a same regression test case in the recommendation result set; if there is a same regression test case in the recommendation result set, extracting all same regression test cases from the recommendation result set, and dividing all same regression test cases according to the number to obtain a plurality of regression test case sets; adding any regression test case from each regression test case set to the recommendation result set to obtain a target recommendation result set.
6. An apparatus for recommending regression test cases, characterized by: comprises: a reading unit configured to read an added transaction test case input by a user and all regression test cases in a case library; a case input unit configured to input the added transaction test case and all regression test cases into a pre-trained word embedding model to obtain a feature vector corresponding to the added transaction test case and feature vectors corresponding to all regression test cases, wherein the word embedding model is composed of a bidirectional automatic encoder-decoder and a bidirectional long short-term memory network; a keyword determination unit configured to determine, for each regression test case, a keyword of the regression test case based on the feature vector corresponding to the added transaction test case and the feature vector corresponding to the regression test case; a syntax feature determination unit configured to determine a syntax feature of the regression test case according to the keyword, and fuse the feature vector corresponding to the regression test case and the syntax feature to obtain a fusion feature; a feature input unit configured to input the fusion feature into a pre-built classifier to obtain a recommendation probability corresponding to the regression test case; a probability determination unit configured to determine whether there are a plurality of target recommendation probabilities greater than a preset threshold in all recommendation probabilities; a case adding unit configured to add, if there are a plurality of target recommendation probabilities greater than a preset threshold in all recommendation probabilities, regression test cases corresponding to the plurality of target recommendation probabilities to a recommendation result set; a de-duplication processing unit configured to perform de-duplication processing on the recommendation result set to obtain a target recommendation result set, and feed back the target recommendation result set to a front end.
7. The apparatus of claim 6, wherein, The keyword determination unit comprises: The computing unit is configured to respectively calculate, for each of the regression test cases, a correlation coefficient between a plurality of words corresponding to the regression test case and the feature vector corresponding to the new transaction test case by using an attention mechanism. The keyword sub-determining unit is configured to filter a maximum correlation coefficient from all the correlation coefficients and determine a word corresponding to the maximum correlation coefficient as a keyword of the regression test case.
8. The apparatus of claim 6, wherein, The syntax feature determining unit comprises: The obtaining unit is configured to obtain a plurality of words corresponding to the regression test case and a correlation coefficient between the plurality of words and the feature vector corresponding to the new transaction test case. The constructing unit is configured to construct an adjacency matrix of the keyword based on the correlation coefficient and the keyword. The first input unit is configured to input the plurality of words corresponding to the regression test case into a Stanford syntax parser to obtain a syntax dependency tree of the regression test case. The sorting unit is configured to sort all the correlation coefficients in descending order and extract a top N correlation coefficient from the sorted correlation coefficients by using a Top-K algorithm. The pruning processing unit is configured to prune the syntax dependency tree of the test case title based on the N correlation coefficients to obtain a target syntax dependency tree. The syntax feature sub-determining unit is configured to update the adjacency matrix according to the target syntax dependency tree and determine the updated adjacency matrix as a syntax feature of the regression test case.
9. The apparatus of claim 6, wherein, The syntax feature determining unit comprises: The second input unit is configured to input the feature vector corresponding to the regression test case into a semantic channel of a graph convolution network for operation to obtain a semantic natural language feature vector corresponding to the regression test case. The third input unit is configured to input the feature vector corresponding to the regression test case and the syntax feature into a syntax channel of the graph convolution network for operation to obtain a syntax natural language feature vector corresponding to the regression test case. The encoding processing unit is configured to perform cascade processing on the semantic natural language feature vector and the syntax natural language feature vector in a feature dimension to obtain a target feature vector and perform encoding processing on the target feature vector to obtain a fusion feature.
10. The apparatus of claim 6, wherein, The deduplication processing unit comprises: The judging unit is configured to determine whether there is a same regression test case in the recommendation result set according to a number of each of the regression test cases in the recommendation result set. The extracting unit is configured to extract all the same regression test cases from the recommendation result set and divide all the same regression test cases according to the number to obtain a plurality of regression test case sets if there is a same regression test case in the recommendation result set. The adding sub-unit is configured to add any one of the regression test cases from each of the regression test case sets to the recommendation result set to obtain a target recommendation result set.
Citation Information
Patent Citations
Test case recommendation method based on semantic index relation
CN117591624A
Regression test method and related system
WO2024109007A1