Software test requirement acquisition method
By extracting keywords in the requirements specification document and matching software testing templates from the expert knowledge base, the problems of incomplete coverage of software testing requirements, low security and low decomposition efficiency in the existing technology are solved, and automated, comprehensive and secure software testing requirements are achieved.
Patent Information
- Application Number
- CN202510067172.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-15
- Publication Date
- 2025-05-23
AI Technical Summary
The existing software testing requirements acquisition methods have incomplete coverage, low security and low decomposition efficiency.
By obtaining requirements specification documentation, extracting chapter names and contents, and obtaining matching software test templates from the expert knowledge base based on extracted keywords as testing requirements. This method uses deep learning models for entity recognition and keyword extraction, and matches them through multi-task learning models and BERT models.
It realizes automated software testing requirements acquisition, improves decomposition efficiency, and more comprehensive and safe requirements, reducing manual intervention and energy consumption.
Smart Images

Figure CN120031011A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a method for obtaining software testing requirements. Background Art
[0002] Software Testing Requirements refer to the conditions and standards that must be met when testing software products during the software development process. These requirements clearly define the quality standards and performance indicators that the software needs to meet to ensure that the software can work as expected and meet user needs.
[0003] In the prior art, testers usually decompose requirements according to the requirements specification, but the coverage of the software functions by the test requirements and sub-items obtained in this way depends largely on the experience of the software testers. If the requirements document is ambiguous or incomplete, it may lead to inaccurate test case design. In addition, the requirements specification needs to be updated and maintained regularly. Especially when the requirements change frequently, the cost of maintaining the document is high, and for some complex business scenarios and interactive logic, it may be difficult to fully cover all test points by relying solely on the requirements specification, and it needs to be supplemented by other testing methods. The coverage of the requirements by the test requirements and sub-items is crucial to the quality of the software. Due to the inadequate decomposition of the requirements, the software security work is missing and the security requirements are insufficient, which further brings security risks to the software products.
[0004] Therefore, a software testing requirements acquisition method with wide coverage, high security and high requirements decomposition efficiency is needed. Summary of the invention
[0005] In view of the above analysis, an embodiment of the present invention aims to provide a method for obtaining software testing requirements, so as to solve the problems of incomplete coverage, low security and low decomposition efficiency of existing software testing requirements.
[0006] An embodiment of the present invention provides a method for obtaining software testing requirements, comprising:
[0007] Obtain a requirement specification document, and extract chapter names and chapter contents from the requirement specification document;
[0008] Extract a first keyword set from the chapter name, extract entity categories and a second keyword set from the chapter content, obtain a software testing template that matches the second keyword set from an expert knowledge base based on the first keyword set, the entity category and the second keyword set, and use the software testing template as the software testing requirement of the requirement specification document.
[0009] Based on a further improvement of the above method, the extracting of entity categories and the second keyword set in the chapter content includes: performing entity recognition and keyword extraction on the chapter content based on a pre-trained first deep learning model to obtain the entity category corresponding to the chapter content and multiple keywords corresponding to the entity category, and the multiple keywords constitute the second keyword set.
[0010] Based on the further improvement of the above method, the expert knowledge base is established by the system user, including professional items, functional items, and test items; wherein the professional items are used to represent the software testing field, the functional items are used to represent the test functions, and the test items are used to represent the execution logic of the test functions.
[0011] Based on a further improvement of the above method, the method of obtaining a software test template that matches the second keyword set from an expert knowledge base based on the first keyword set, the entity category and the second keyword set includes: determining professional items in the expert knowledge base based on the first keyword set, and under each professional item, determining multiple functional items based on the entity category, and for each functional item, determining a test item based on matching the second keyword set, and using all matching test items as a software test template that matches the second keyword set.
[0012] Based on the further improvement of the above method, the test item includes the test content and its corresponding test execution logic;
[0013] The method of determining the test items based on matching the second keyword set includes: extracting the third keyword set of each test item based on a pre-trained second deep learning model, calculating the similarity between the second keyword set and the third keyword set of each test item, and adding the test items corresponding to the third keyword set whose similarity is greater than a preset threshold as a matching result to a target matching result set; for each matching result in the target matching result set, calculating a matching score based on the similarity corresponding to the matching result and a user feedback result, and taking the matching result with the highest matching score as the test item corresponding to the second keyword set.
[0014] Based on the further improvement of the above method, the user feedback result refers to the score given by the historical users to the test item under the entity type, which is used to indicate the degree to which the test item meets the test requirements;
[0015] The calculating of the matching score based on the similarity corresponding to the matching result and the user feedback result includes:
[0016]
[0017] α, β are constants, X 1 is the vector corresponding to the second keyword set, X2 is the vector corresponding to the third keyword set of the test item, n is the number of user feedback results, θ i is the feedback result of the i-th user, and k is the number of users.
[0018] Based on the further improvement of the above method, the first deep learning model is a multi-task learning model, whose input data is chapter content, and the output data is entity categories and multiple keywords corresponding to the entity categories; the second deep learning model is a BERT model.
[0019] Based on the further improvement of the above method, the method also includes: after obtaining the trained first deep learning model, performing a pruning operation on it.
[0020] Based on the further improvement of the above method, the pruning operation includes: obtaining the weight set of each layer in the shared layer of the first deep learning model, optimizing the weight set of each layer based on the particle swarm algorithm, and calculating the weight change ratio of each weight in the weight set, and sorting the weight change ratio of each layer from small to large to obtain a first sorting result; calculating the importance of each layer in the shared layer based on sensitivity analysis, and sorting the shared layers in order of importance from small to large to obtain a second sorting result; completing the pruning operation based on the first sorting result and the second sorting result.
[0021] Based on the further improvement of the above method, the particle swarm algorithm is used to optimize the weight set of each layer and calculate the weight change ratio of each weight in the weight set, including:
[0022] A1: Initialize the particle swarm, take the weight of the layer as the original weight, and take the original weight as a particle, randomly select a value in the range of 0 to 1 based on a random generation algorithm, thereby generating multiple particles so that the total number of particles meets the preset number requirement;
[0023] A2: Calculate the fitness function of each particle to update the individual optimal and global optimal values, and determine whether the end condition is met. If so, execute A4; if not, execute A3;
[0024] A3: Update the speed and position of each particle and return to A2;
[0025] A4: Output the optimal position. The particle corresponding to the optimal position is the optimal weight of the layer.
[0026] A5: Calculate the weight change ratio corresponding to each neuron in this layer:
[0027]
[0028] w i_newis the optimal weight of the neuron, w i_old is the original weight of the neuron, i is the number of neurons in the layer, i = 1, 2, 3, ..., N;
[0029] A6: Execute steps A1-A5 for each layer in the shared layer to obtain the weight change ratio corresponding to each neuron in each layer;
[0030] The completing the pruning operation based on the first sorting result and the second sorting result includes:
[0031] B1: Obtain the first shared layer in the second sorting result, and obtain the first sorting result corresponding to the shared layer, delete the neurons in the first sorting result that are greater than the preset ratio threshold, and calculate whether the current pruning rate meets the preset pruning threshold. If so, stop pruning; if not, execute B2;
[0032] B2: Obtain the next shared layer in the second sorting result, and obtain the first sorting result corresponding to the shared layer, delete the neurons in the first sorting result that are greater than the preset ratio threshold, and calculate whether the current pruning rate meets the preset pruning threshold. If so, stop pruning; if not, repeat B2 until the preset pruning threshold is met.
[0033] Compared with the prior art, the present invention can achieve at least one of the following beneficial effects:
[0034] 1. The present invention provides a method for obtaining software testing requirements. The software testing requirements corresponding to the requirement specification document can be obtained by matching the current requirement specification document with the expert knowledge base. It does not require manual intervention and is an automated method. Therefore, compared with the traditional method that requires testers to manually decompose the test requirements, the method proposed by the present invention improves the decomposition efficiency. In addition, the expert knowledge base stores a wealth of software testing templates, and each software testing template is formed by testers after strict screening and multiple debugging. Therefore, the software testing requirements obtained based on matching are more comprehensive and safer than the traditional manual decomposition method.
[0035] 2. The present invention provides a method for obtaining software testing requirements. After obtaining a multi-task learning model, a pruning operation is performed on it, which can effectively reduce the amount of calculation and memory requirements, improve model efficiency and generalization ability, and reduce energy consumption. In the pruning operation, the weight change ratio of each neuron is obtained based on the result of the particle swarm algorithm, so that the neurons to be deleted can be selected more quickly in the pruning operation.
[0036] In the present invention, the above-mentioned technical solutions can also be combined with each other to achieve more preferred combination solutions. Other features and advantages of the present invention will be described in the subsequent description, and some advantages can become obvious from the description, or can be understood by practicing the present invention. The purpose and other advantages of the present invention can be realized and obtained through the contents particularly pointed out in the description and the drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The accompanying drawings are only used for the purpose of illustrating specific embodiments and are not to be considered as limiting the present invention. In the entire drawings, the same reference symbols represent the same components;
[0038] Figure 1 The figure is an example diagram of a method for obtaining software testing requirements in an embodiment of the present invention. DETAILED DESCRIPTION
[0039] The preferred embodiments of the present invention are described in detail below in conjunction with the accompanying drawings, wherein the accompanying drawings constitute a part of this application and are used together with the embodiments of the present invention to illustrate the principles of the present invention, but are not used to limit the scope of the present invention.
[0040] Multi-task learning (MTL) is a machine learning paradigm that aims to improve the generalization ability of the model by learning multiple related tasks simultaneously. It can effectively reduce maintenance costs and solve the problem of sample bias. The core idea is to share some parameters or feature representations of the model so that different tasks can benefit from each other. Hard parameter sharing and soft parameter sharing are typical implementation methods of multi-task models. Shared Bottom and MMoE (Multi-gate Mixture-of-Experts) are typical multi-task model structures. Specifically, in Shared Bottom, all tasks share a bottom network, and then output the results through task-specific tower networks. This structure is simple and has many parameter sharing, but it has high requirements for task relevance. MmoE selects the output of the expert network through multiple gating mechanisms, allowing more flexible parameter sharing between tasks. Compared with Shared Bottom, MMoE performs better when the task relevance is low. Multi-task learning has applications in many fields, such as natural language processing, computer vision, and healthcare.
[0041] BERT (Bidirectional Encoder Representations from Transformers) is a pre-trained language model released by Google in 2018. It aims to improve the ability of natural language understanding through deep bidirectional Transformer encoders. BERT performs well in a variety of natural language processing tasks, including but not limited to: text classification, such as sentiment analysis, topic classification, etc.; question answering system: able to understand the semantics of questions and generate accurate answers; named entity recognition (NER), identifying entities in text, such as names, organizations, etc.; machine translation, improving translation accuracy by learning the mapping relationship between different languages; text summarization, generating concise and meaningful text summaries.
[0042] A Software Requirement Specification (SRS) is a document that describes the functional and non-functional requirements of a software product or system in detail. It describes in detail the functions, performance, interfaces and other requirements of the software system, including: (1) Introduction, including purpose, background, definitions, abbreviations and terms, references, etc.; (2) Overall description, such as product perspective, user characteristics, constraints, assumptions and dependencies; (3) Functional requirements, such as functional modules, including functional description: detailed description of the function and purpose of the module; user interface: description of the layout, elements and interaction methods of the user interface; business rules: listing the business rules and logic related to the function; security requirements: describing the security requirements and measures of the function; (4) Non-functional requirements, including performance requirements, reliability requirements, availability requirements, security requirements, compatibility requirements, maintainability requirements; (5) Priority and sorting, including requirement priority, etc.; (6) Appendix, including version history, recording the version number, modification date, modifier and modification content of the document, etc.
[0043] A specific embodiment of the present invention discloses a method for obtaining software testing requirements, such as Figure 1 As shown, including:
[0044] S1: Obtain a requirement specification document, and extract chapter names and chapter contents from the requirement specification document.
[0045] The present invention uses the Apache POI framework to extract a chapter directory, which includes a chapter number and a chapter name. After extracting the chapter directory, the chapter content under the chapter name is further extracted. After obtaining the chapter number, chapter name, and chapter content, manual review can be performed to ensure that the chapter name and the chapter content correspond one to one, thereby reducing the probability of subsequent matching errors to a certain extent. After the manual review is completed, the chapter number, chapter name, and chapter content are stored in a database according to the corresponding relationship between the three, so as to facilitate subsequent calls.
[0046] Of course, the solution proposed by the present invention may not require manual review. For example, if the software testing requirements in the business requirements are relatively few, and the chapter names and chapter contents extracted from the requirements specification document are also relatively few, then manual review is not required. It is understandable that manual review can further improve the accuracy of subsequent matching, and testers can choose whether to conduct a review based on actual needs.
[0047] For example, the content of Section 3.21 of the requirements specification document is as follows:
[0048] 3.21 Automotive system command parsing function
[0049] After the car power supply system is started, it enters the waiting command receiving stage and sends command data to the engine and fuel tank regularly according to the car communication protocol. In the waiting command receiving state, only steering commands and driving commands are received and processed, and other commands are invalid.
[0050] After receiving a valid steering command during the waiting for command reception stage, the function of direction determination is turned on. After receiving a valid driving command during the waiting for command reception stage, the function of ground driving speed determination is turned on.
[0051] For steering commands, only when the Gray code and command length conform to the vehicle communication protocol, the command is considered valid, otherwise it is invalid.
[0052] For driving commands, only when the secondary coding and command length conform to the vehicle communication protocol and the verification is successful, the command is considered valid, otherwise it is invalid.
[0053] Engine data sending cycle: 38s; fuel tank data sending cycle: 52s.
[0054] S2: Extract a first keyword set from the chapter name, extract an entity category and a second keyword set from the chapter content, obtain a software testing template that matches the second keyword set from an expert knowledge base based on the first keyword set, the entity category and the second keyword set, and use the software testing template as the software testing requirement of the requirement specification document.
[0055] The expert knowledge base is established by the system user, including professional items, functional items, and test items; wherein the professional items are used to represent the software testing field, the functional items are used to represent the test function, the test items are used to represent the execution logic of the test function, and the test items include the test content and its corresponding test execution logic. The content stored in the expert knowledge base is composed of high-quality test files that have been screened. It can be understood that a large number of software test templates are stored in the expert knowledge base, which can meet the daily needs of users, and the expert knowledge base also supports updating, modification and deletion. When a new test case template appears and the expert knowledge base is not stored, the system user can submit the edited test template to the system, and after approval by the professional person in charge and the evaluation professional expert, the administrator completes the addition operation; when the content in the expert knowledge base needs to be modified or deleted, the user initiates an application and submits the approval process, and after approval by the professional person in charge and the evaluation professional expert, the administrator performs the modification or deletion operation. The above method is to ensure that each test template in the expert knowledge base can meet the test standards, and can ensure that the terms of each test template are in line with the professional background, so as to further improve the matching efficiency, thereby improving the test efficiency to a certain extent.
[0056] For example, the professional item may be automobile professional, the functional item may be automobile system command parsing function test, and the functional item may be: (1) Functional test of waiting to receive instructions: power the automobile through the test equipment, start it, observe the waiting to receive instructions information received on the automobile screen, and verify the correctness of the waiting to receive instructions function. (2) Functional test of receiving steering commands in the waiting to receive instructions state: verify the normal and abnormal situations of steering commands respectively, a) send a normal steering command to the automobile through the test equipment, and the test equipment displays the information that the automobile correctly responds to the steering command; b) in the simulation mode environment, send an abnormal steering command to the automobile through the test equipment, and the test equipment displays that the automobile is still in the waiting to receive instructions state. (3) Functional test of receiving driving commands in the waiting to receive instructions state: verify the normal and abnormal situations of driving commands respectively, a) send a normal driving command to the automobile through the test equipment, and the test equipment displays the information that the automobile correctly responds to the driving command; b) in the simulation mode environment, send an abnormal driving command to the automobile through the test equipment, and the test equipment displays that the automobile is still in the waiting to receive instructions state. (4) Performance test of the data transmission cycle to the engine: In the state of waiting to receive instructions, use an oscilloscope to measure the data output to the engine port to check whether the data packet transmission cycle is 38s, and verify the performance test of the data transmission cycle to the engine. (5) Performance test of the data transmission cycle to the fuel tank: In the state of waiting to receive instructions, use an oscilloscope to measure the signal output to the fuel tank port to check whether the data packet transmission cycle is 52s, and verify the performance test of the data transmission cycle to the fuel tank.
[0057] In the prior art, there are many methods for extracting keywords, for example, methods based on statistics (word frequency statistics method, TF-IDF method, etc.) and methods based on language models (such as RNN, LSTM, BERT, etc.).
[0058] Exemplarily, the present invention uses the BERT model to extract keywords, and obtains an available BERT model in the following manner: obtain a text content set (such as a chapter name), perform keyword recognition on each text content in the text content set based on the BIOES method, convert the text content set into a text vector set based on the Word2Vec model, and use each text in the text vector set and its corresponding keyword as a data sample, thereby constructing a data sample set. The data sample set is divided into a training set and a test set according to a certain ratio, a text vector is used as input data, and the keyword corresponding to the text vector is used as output data. The training set is used to train the BERT model, and the trained BERT model is tested using the test set. If the test result meets the preset conditions, a BERT model that meets the requirements is obtained. Meeting the preset conditions means that the results of precision, accuracy, recall and F1 Score meet user expectations. Preferably, the sample set is split into a training set and a test set in a ratio of 8:2. Preferably, the preset length of the text vector generated by the Word2Vec model is set, and the converted text vector meets the preset length by adding zero elements at the end of the vector or using a truncation operation.
[0059] The extraction of chapter name keywords in the present invention can be implemented by the BERT model obtained in the above manner. The second deep learning model in the present invention can also be obtained in the above manner.
[0060] The extracting of entity categories and a second keyword set from the chapter content includes: performing entity recognition and keyword extraction on the chapter content based on a pre-trained first deep learning model to obtain an entity category corresponding to the chapter content and a plurality of keywords corresponding to the entity category, wherein the plurality of keywords constitute a second keyword set.
[0061] The first deep learning model is a multi-task learning model, which is usually composed of an input layer, a shared layer and a task-specific layer. The input data of the multi-task model in the present invention is the chapter content, and the output data is the entity category and multiple keywords corresponding to the entity category. Specifically, the model uses hard parameter sharing to realize parameter sharing. The shared layer includes multiple convolutional layers, LSTM layers, Transformer layers and Relu Layer layers. The task-specific layer includes multiple convolutional layers, Relu Layer, Dropout Layer, and a fully connected layer. The prediction result is output by the last fully connected layer. The present invention includes 2 task-specific layers, one task-specific layer is used to output entity types, and one task-specific layer is used to output keywords. It can be understood that the chapter content needs to be converted into a vector form through the Word2Vec model. If the generated text vector does not meet the preset length, the converted text vector can be made to meet the preset length by adding zero elements at the end of the vector or by using a truncation operation. Here, the training process of the first deep learning model is not specifically limited, so as to be able to obtain the entity category and multiple keywords corresponding to the entity category based on the chapter content. The entity type may be equipment, hardware, parameters, or data. The present invention does not impose any limitation on this. The entity type may be limited according to business requirements as long as it corresponds to the functional items in the expert knowledge base.
[0062] Preferably, after obtaining the trained first deep learning model, a pruning operation can also be performed on it. Specifically, the present invention performs a pruning operation on the shared layer, so the input layer and the shared layer in the trained multi-task learning model are first extracted, and a new fully connected layer is added thereafter to form a network to be pruned. The pruning operation is essentially to operate the shared layer in the pruned network. After the pruning is completed, the original task-specific layer is connected to form a lightweight network. The pruning operation includes:
[0063] N1: Obtain the weight set of each layer in the shared layer of the first deep learning model, optimize the weight set of each layer based on the particle swarm algorithm, calculate the weight change ratio of each weight in the weight set, and sort the weight change ratio of each layer from small to large to obtain the first sorting result.
[0064] The particle swarm algorithm is used to optimize the weight set of each layer and calculate the weight change ratio of each weight in the weight set, including:
[0065] A1: Initialize the particle swarm, take the weight of the layer as the original weight, and take the original weight as a particle, randomly select a value in the range of 0 to 1 based on a random generation algorithm, thereby generating multiple particles so that the total number of particles meets the preset number requirement.
[0066] Exemplarily, the preset number is 10.
[0067] A2: Calculate the fitness function of each particle to update the individual optimal and global optimal values, and determine whether the end condition is met. If so, execute A4; if not, execute A3.
[0068] Among them, the fitness function is:
[0069]
[0070] y new_sample The corresponding value of the particle is used as the weight value of the neuron in this layer, and the result obtained by using the network to be pruned to predict the sample sample, y i_sample The result obtained by using the original weights of this layer as the weights of the neurons in this layer and using the network to be pruned to predict the sample-th sample, sample = 1, 2, 3, ..., N.
[0071] A3: Update the speed and position of each particle and return to A2.
[0072] A4: Output the optimal position. The particle corresponding to the optimal position is the optimal weight of the layer.
[0073] A5: Calculate the weight change ratio corresponding to each neuron in this layer:
[0074]
[0075] w i_new is the optimal weight of the neuron, w i_old is the original weight of the neuron, i is the number of neurons in the layer, i = 1, 2, 3, ..., N.
[0076] A6: Execute steps A1-A5 for each layer in the shared layer to obtain the weight change ratio corresponding to each neuron in each layer.
[0077] By applying the particle swarm algorithm, the present invention obtains the influence of each neuron in each layer on the prediction result (i.e., the weight change ratio), which shows the sensitivity of each neuron to the accuracy improvement. If the weight change ratio is large, it means that the weight of the neuron needs to be changed greatly to achieve the preset accuracy, so the importance of the neuron is low; if the weight change ratio is small, it means that the weight of the neuron only needs to be slightly changed to achieve the preset accuracy, so the importance of the neuron is high. The speed, position update method and other contents in the particle swarm algorithm are common knowledge in the art and will not be introduced here.
[0078] N2: Calculate the importance of each shared layer based on sensitivity analysis, and sort the shared layers in ascending order of importance to obtain a second sorting result.
[0079] The importance can be calculated based on sensitivity analysis by using the differential method, model output change method, variance decomposition method, etc. The present invention does not make any limitation here, as long as the importance of each layer in the shared layer can be correctly obtained.
[0080] N3: completing a pruning operation based on the first sorting result and the second sorting result, including:
[0081] B1: Obtain the first shared layer in the second sorting result, and obtain the first sorting result corresponding to the shared layer, delete the neurons in the first sorting result that are greater than the preset ratio threshold, and calculate whether the current pruning rate meets the preset pruning threshold. If so, stop pruning; if not, execute B2;
[0082] B2: Obtain the next shared layer in the second sorting result, and obtain the first sorting result corresponding to the shared layer, delete the neurons in the first sorting result that are greater than the preset ratio threshold, and calculate whether the current pruning rate meets the preset pruning threshold. If so, stop pruning; if not, repeat B2 until the preset pruning threshold is met.
[0083] Exemplarily, the preset pruning threshold is 20%.
[0084] The acquiring a software test template matching the second keyword set from an expert knowledge base based on the first keyword set, the entity category and the second keyword set includes:
[0085] Based on the first keyword set, professional items are determined in the expert knowledge base. Under each professional item, multiple functional items are determined based on the entity category. For each functional item, test items are determined based on matching with the second keyword set, and all matching test items are used as software test templates that match the second keyword set.
[0086] The determining the test item based on the matching of the second keyword set includes:
[0087] Extracting the third keyword set of each test item based on the pre-trained second deep learning model, calculating the similarity between the second keyword set and the third keyword set of each test item, and adding the test item corresponding to the third keyword set with a similarity greater than a preset threshold as a matching result to the target matching result set;
[0088] For each matching result in the target matching result set, a matching score is calculated based on the similarity corresponding to the matching result and the user feedback result, and the matching result with the highest matching score is used as the test item corresponding to the second keyword set.
[0089] Exemplarily, the second deep learning model is a BERT model, the construction of which has been introduced above. The preset threshold is 0.75, that is, if the similarity is greater than 0.75, the two can be considered to match. The user feedback result refers to the historical user's score for the test item under the entity type, which is used to indicate the degree to which the test item meets the test requirements.
[0090] The calculating of the matching score based on the similarity corresponding to the matching result and the user feedback result includes:
[0091]
[0092] α, β are constants, X 1 is the vector corresponding to the second keyword set, X 2 is the vector corresponding to the third keyword set of the test item, n is the number of user feedback results, θ i is the feedback result of the i-th user, and k is the number of users.
[0093] Compared with the prior art, the method for obtaining software testing requirements provided in this embodiment can obtain the software testing requirements corresponding to the requirement specification document by matching the current requirement specification document with the expert knowledge base. It does not require manual intervention and is an automated method. In addition, the expert knowledge base stores a wealth of software testing templates, and each software testing template is formed by testers after strict screening and multiple debugging. Therefore, the software testing requirements obtained based on matching are more comprehensive and safer than those obtained by traditional manual decomposition. In addition, after obtaining the multi-task learning model, pruning it can effectively reduce the amount of calculation and memory requirements, improve model efficiency and generalization ability, and reduce energy consumption. In the pruning operation, the weight change ratio of each neuron is obtained based on the results of the particle swarm algorithm, so that the neurons to be deleted can be selected more quickly in pruning.
[0094] Those skilled in the art will appreciate that all or part of the processes of the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, wherein the computer-readable storage medium is a disk, an optical disk, a read-only storage memory, or a random access memory, etc.
[0095] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed by the present invention should be covered within the protection scope of the present invention.
Claims
1. A method for obtaining software testing requirements, characterized in that: include: Obtain a requirement specification document, and extract chapter names and chapter contents from the requirement specification document; Extract a first keyword set from the chapter name, extract entity categories and a second keyword set from the chapter content, obtain a software testing template that matches the second keyword set from an expert knowledge base based on the first keyword set, the entity category and the second keyword set, and use the software testing template as the software testing requirement of the requirement specification document.
2. A method for obtaining software testing requirements according to claim 1, characterized in that: The extracting of the entity category and the second keyword set from the chapter content includes: Based on a pre-trained first deep learning model, entity recognition and keyword extraction are performed on the chapter content to obtain an entity category corresponding to the chapter content and multiple keywords corresponding to the entity category, and the multiple keywords constitute a second keyword set.
3. A method for obtaining software testing requirements according to claim 2, characterized in that: include: The expert knowledge base is established by system users and includes professional items, functional items, and test items; wherein the professional items are used to represent the software testing field, the functional items are used to represent the test functions, and the test items are used to represent the execution logic of the test functions.
4. A method for obtaining software testing requirements according to claim 3, characterized in that: The acquiring a software test template matching the second keyword set from an expert knowledge base based on the first keyword set, the entity category and the second keyword set includes: Based on the first keyword set, professional items are determined in the expert knowledge base. Under each professional item, multiple functional items are determined based on the entity category. For each functional item, test items are determined based on matching with the second keyword set, and all matching test items are used as software test templates that match the second keyword set.
5. A method for obtaining software testing requirements according to claim 4, characterized in that: The test items include test content and its corresponding test execution logic; The determining the test item based on the matching of the second keyword set includes: Extracting the third keyword set of each test item based on the pre-trained second deep learning model, calculating the similarity between the second keyword set and the third keyword set of each test item, and adding the test item corresponding to the third keyword set with a similarity greater than a preset threshold as a matching result to the target matching result set; For each matching result in the target matching result set, a matching score is calculated based on the similarity corresponding to the matching result and the user feedback result, and the matching result with the highest matching score is used as the test item corresponding to the second keyword set.
6. A method for obtaining software testing requirements according to claim 5, characterized in that: The user feedback result refers to the historical user's score on the test item under the entity type, which is used to indicate the degree to which the test item meets the test requirements; The calculating of the matching score based on the similarity corresponding to the matching result and the user feedback result includes: α and β are constants, X1 is the vector corresponding to the second keyword set, X2 is the vector corresponding to the third keyword set of the test item, n is the number of user feedback results, θ i is the feedback result of the i-th user, and k is the number of users.
7. A method for obtaining software testing requirements according to claim 6, characterized in that: include: The first deep learning model is a multi-task learning model, whose input data is chapter content, and whose output data is entity categories and multiple keywords corresponding to the entity categories; The second deep learning model is the BERT model.
8. A method for obtaining software testing requirements according to claim 7, characterized in that: The method further comprises: After obtaining the trained first deep learning model, a pruning operation is performed on it.
9. A method for obtaining software testing requirements according to claim 8, characterized in that: The pruning operation includes: Obtain the weight set of each layer in the shared layer of the first deep learning model, optimize the weight set of each layer based on the particle swarm algorithm, calculate the weight change ratio of each weight in the weight set, and sort the weight change ratio of each layer from small to large to obtain a first sorting result; The importance of each layer in the shared layer is calculated based on the sensitivity analysis, and the shared layers are sorted in order of importance from small to large to obtain a second sorting result; A pruning operation is performed based on the first sorting result and the second sorting result.
10. A method for obtaining software testing requirements according to claim 9, characterized in that: The particle swarm algorithm is used to optimize the weight set of each layer and calculate the weight change ratio of each weight in the weight set, including: A1: Initialize the particle swarm, take the weight of the layer as the original weight, and take the original weight as a particle, randomly select a value in the range of 0 to 1 based on a random generation algorithm, thereby generating multiple particles so that the total number of particles meets the preset number requirement; A2: Calculate the fitness function of each particle to update the individual optimal and global optimal values, and determine whether the end condition is met. If so, execute A4; if not, execute A3; A3: Update the speed and position of each particle and return to A2; A4: Output the optimal position. The particle corresponding to the optimal position is the optimal weight of the layer. A5: Calculate the weight change ratio corresponding to each neuron in this layer: w i_new is the optimal weight of the neuron, w i_old is the original weight of the neuron, i is the number of neurons in the layer, i = 1, 2, 3, ..., N; A6: Execute steps A1-A5 for each layer in the shared layer to obtain the weight change ratio corresponding to each neuron in each layer; The completing the pruning operation based on the first sorting result and the second sorting result includes: B1: Obtain the first shared layer in the second sorting result, and obtain the first sorting result corresponding to the shared layer, delete the neurons in the first sorting result that are greater than the preset ratio threshold, and calculate whether the current pruning rate meets the preset pruning threshold. If so, stop pruning; if not, execute B2; B2: Obtain the next shared layer in the second sorting result, and obtain the first sorting result corresponding to the shared layer, delete the neurons in the first sorting result that are greater than the preset ratio threshold, and calculate whether the current pruning rate meets the preset pruning threshold. If so, stop pruning; if not, repeat B2 until the preset pruning threshold is met.