A neural network-based test case generation method
Patent Information
- Application Number
- CN202211435580.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-16
- Publication Date
- 2026-09-04
- Estimated Expiration
- 2042-11-16
AI Technical Summary
[0005]本发明克服了现有技术的不足之一,提供了一种基于神经网络的测试用例生成方法,能够解决研发测试阶段测试用例设计人力投入大、耗时长、以及由于人为主观因素导致的漏检漏测等问题,实现快速构建测试用例,缓解测试人力压力,在研发测试阶段提供及时全面的质量保障
[0031] The advantages of this disclosure lie in the following: The test case generation method based on neural networks collects historical project documents as raw data; it extracts keywords and labels test cases from the raw data to obtain a training dataset for constructing a test case prediction model; the training dataset is input into the neural network-based test case prediction model to output predicted test cases; manual intervention corrects the predicted test cases, and the corrected predicted test cases are then used as the training dataset to back-input into the test case prediction model for fine-tuning. This solves the problem of testers spending too much time on test case design during the R&D testing process, allowing them to focus on higher-level testing tasks, increasing the ratio of business R&D testing to testing, and alleviating the pressure on testing manpower; it also improves test scenario coverage, avoids missed tests and inspections caused by subjective human factors, and thus provides timely and comprehensive quality assurance during the R&D testing phase.
Smart Images

Figure CN115757124B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of test case generation technology, and specifically relates to a test case generation method based on neural networks. Background Technology
[0002] Test cases are the cornerstone of ensuring test quality in software testing. Designing high-quality test cases with minimal manpower, resources, and time to improve testing efficiency and help quickly discover and locate hidden defects during the development and testing process, thereby ensuring software quality, is an important goal in the field of software testing.
[0003] Machine learning methods learn from historical sample data, uncover hidden features, and obtain prediction results through weighted combinations of these features. The idea of extracting test cases from raw data such as requirements documents and design documents can be seen as a problem in the field of natural language processing, making it very suitable for use in deep learning models such as convolutional neural networks and recurrent neural networks to extract test case features. Furthermore, combining machine learning with test case generation methods that learn from historically accumulated test case data aligns with the trend of the big data era, making the most of data.
[0004] Existing patents' test case generation methods mostly focus on improving scenario coverage, covering abnormal scenarios, or selecting steps from a maintained test step library for combination and recommendation. Test cases still require further human involvement in the design based on the predicted results. Summary of the Invention
[0005] This invention overcomes one of the shortcomings of the prior art by providing a test case generation method based on neural networks. It can solve the problems of high manpower investment and long time consumption in test case design during the R&D testing phase, as well as the omissions and missed tests caused by human subjective factors. It enables rapid construction of test cases, alleviates the pressure on testing manpower, and provides timely and comprehensive quality assurance during the R&D testing phase.
[0006] According to one aspect of this disclosure, a test case generation method based on neural networks is proposed, the method comprising:
[0007] Collect historical project documents and use them as raw data;
[0008] The original data is processed by keyword extraction and test case labeling to obtain a training dataset for building a test case prediction model;
[0009] The training dataset is input into a neural network-based test case prediction model, which outputs predicted test cases.
[0010] The predicted test cases are corrected by manual intervention, and the corrected predicted test cases are used as training datasets to be input back into the test case prediction model for fine-tuning.
[0011] In one possible implementation, the raw data includes requirements documents, design documents, and test cases.
[0012] In one possible implementation, the step of extracting keywords and labeling test cases from the original data to obtain a training dataset for constructing a test case prediction model includes:
[0013] Use word segmentation tools to extract keywords from requirements documents and design documents to obtain a keyword set;
[0014] The test cases are tagged, broken down into steps, and hot-read encoded to obtain a test case tag set;
[0015] The training dataset for the test case prediction model is constructed based on the keyword set and the test case tag set.
[0016] In one possible implementation, the test case prediction model includes a scenario classifier and a process predictor for test case feature extraction.
[0017] In one possible implementation, inputting the training dataset into a neural network-based test case prediction model and outputting predicted test cases includes:
[0018] The scene classifier extracts scene classification features from the training dataset, and the process predictor extracts test case step sequence information from the training dataset. The scene classification features and the test case step sequence information are fused together to automatically generate predicted test cases.
[0019] In one possible implementation, the scene classifier is a deep learning model based on a convolutional neural network; and the process predictor is a process test case prediction model based on a recurrent neural network.
[0020] In one possible implementation, the process predictor extracts test case step sequence information from the training dataset, including:
[0021] The training dataset is input into a process predictor based on a recurrent neural network for learning, thereby obtaining the current sequence features of the test cases in the training dataset;
[0022] The current sequence features of the test cases and the previous sequence memory features of the test cases are fused to obtain the timing information of the current sequence of the test cases, and the timing information of the current sequence of the test cases is saved to the memory unit of the process predictor.
[0023] Repeat the above steps until the temporal characteristics of the test cases are extracted, and the test case step sequence information is obtained.
[0024] According to another aspect of this disclosure, a test case generation apparatus based on a neural network is proposed, the apparatus comprising:
[0025] The collection module is used to collect historical project documents and use these historical project documents as raw data.
[0026] The preprocessing module is used to extract keywords and label test cases from the raw data to obtain a training dataset for building a test case prediction model.
[0027] The test case prediction module is used to input the training dataset into the neural network-based test case prediction model and output predicted test cases.
[0028] The correction module is used to manually correct the predicted test cases and input the corrected predicted test cases as a training dataset into the test case prediction model to fine-tune the test case prediction model.
[0029] According to another aspect of this disclosure, an electronic device is proposed, the device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the method described above.
[0030] According to another aspect of this disclosure, a computer-readable storage medium is provided that stores a computer program, which, when executed by a processor, implements the method described above.
[0031] The advantages of this disclosure lie in the following: The test case generation method based on neural networks collects historical project documents as raw data; it extracts keywords and labels test cases from the raw data to obtain a training dataset for constructing a test case prediction model; the training dataset is input into the neural network-based test case prediction model to output predicted test cases; manual intervention corrects the predicted test cases, and the corrected predicted test cases are then used as the training dataset to back-input into the test case prediction model for fine-tuning. This solves the problem of testers spending too much time on test case design during the R&D testing process, allowing them to focus on higher-level testing tasks, increasing the ratio of business R&D testing to testing, and alleviating the pressure on testing manpower; it also improves test scenario coverage, avoids missed tests and inspections caused by subjective human factors, and thus provides timely and comprehensive quality assurance during the R&D testing phase. Attached Figure Description
[0032] The accompanying drawings are used to provide a further understanding of the technical solutions of this application or the prior art, and constitute a part of the specification. The drawings illustrating embodiments of this application, together with the embodiments of this application, are used to explain the technical solutions of this application, but do not constitute a limitation on the technical solutions of this application.
[0033] Figure 1 A flowchart of a test case generation method based on a neural network according to an embodiment of the present disclosure is shown;
[0034] Figure 2 A flowchart of training dataset preprocessing according to an embodiment of the present disclosure is shown;
[0035] Figure 3 A schematic diagram illustrating the principle of extracting test case step sequence information of a process predictor according to an embodiment of the present disclosure is shown.
[0036] Figure 4 A flowchart illustrating the working principle of a test case prediction model according to an embodiment of the present disclosure is shown.
[0037] Figure 5 A flowchart of a neural network-based test case generation method according to another embodiment of the present disclosure is shown;
[0038] Figure 6 A schematic diagram of the structure of a neural network-based test case generation apparatus according to an embodiment of the present disclosure is shown;
[0039] Figure 7 A schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure is shown. Detailed Implementation
[0040] The embodiments of the present invention will be described in detail below with reference to the accompanying drawings and examples, so that the process of how the present invention uses technical means to solve technical problems and achieve corresponding technical effects can be fully understood and implemented accordingly. The embodiments of this application and the various features in the embodiments can be combined with each other without conflict, and the resulting technical solutions are all within the protection scope of the present invention.
[0041] Furthermore, the steps illustrated in the flowcharts of the accompanying drawings can be executed in a computer, such as a set of computer-executable instructions. Also, although a logical order is shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than that presented here.
[0042] Figure 1 A flowchart of a neural network-based test case generation method according to an embodiment of this disclosure is shown. Figure 1 As shown, the method may include:
[0043] Step S1: Collect historical project documents and use them as raw data. These historical project documents may include requirement documents, design documents, and test cases, which will be used as raw data for the test case prediction model.
[0044] Step S2: Extract keywords and label test cases from the raw data to obtain the training dataset for building the test case prediction model.
[0045] Figure 2 A flowchart of training dataset preprocessing according to an embodiment of the present disclosure is shown.
[0046] In one example, such as Figure 2 As shown, the step of extracting keywords and labeling test cases from the original data to obtain the training dataset for constructing the test case prediction model may include:
[0047] Keyword sets are obtained by extracting keywords from requirements and design documents using word segmentation tools. Test cases are then tagged, broken down into steps, and encoded using hot-read encoding to obtain test case tag sets. A training dataset for the test case prediction model is constructed based on the keyword set and the test case tag set. Keyword extraction may include key term extraction and test step extraction, resulting in keyword samples and test case step identifiers.
[0048] Step S3: Input the training dataset into the neural network-based test case prediction model and output predicted test cases.
[0049] Among them, the test case prediction model can be obtained by extracting test case features based on natural language processing techniques such as convolutional neural networks and recurrent neural networks, thereby realizing the automatic generation of test cases.
[0050] The test case prediction model consists of a scenario classifier (horizontal scenario classification submodule) and a process predictor (vertical process generation submodule).
[0051] The scene classifier can be a deep learning model based on convolutional neural networks and their variants. The scene classifier (lateral scene classification sub-model) mainly learns to extract scene classification features from the training dataset (test case training samples).
[0052] The process predictor can be a process test case prediction model based on recurrent neural networks and their variants. The process predictor (vertical process generation sub-model) learns to extract test case step sequence information from the training dataset (test case training samples). Finally, by fusing scene classification features and process sequence information (i.e., test case step sequence information) from two dimensions, a test case prediction model is obtained, which automatically generates predicted test cases.
[0053] Figure 3 A schematic diagram illustrating the principle of extracting test case step sequence information of a process predictor according to an embodiment of the present disclosure is shown.
[0054] In one example, the process predictor extracts test case step sequence information from the training dataset, including:
[0055] The training dataset is input into a process predictor based on a recurrent neural network for learning, thereby obtaining the current sequence features of the test cases in the training dataset;
[0056] The current sequence features of the test cases and the previous sequence memory features of the test cases are fused to obtain the timing information of the current sequence of the test cases, and the timing information of the current sequence of the test cases is saved to the memory unit of the process predictor.
[0057] Repeat the above steps until the temporal characteristics of the test cases are extracted, and the test case step sequence information is obtained.
[0058] like Figure 3 As shown, the process predictor includes multiple memory units, which are used to store timing information of test cases.
[0059] The training dataset is sequentially input into the recurrent neural network. The recurrent neural network is responsible for learning the current sequence features of the test cases in the training dataset and the stored memory features of the previous sequence of the test cases. The timing information of the current sequence of the test cases is obtained through feature fusion and stored in the memory unit. The neural network calculation is performed in this sequential loop to achieve the purpose of extracting timing features and realize the ability to generate test case step sequence information in sequence.
[0060] Step S4: Manually intervene to correct the predicted test cases, and use the corrected predicted test cases as a training dataset to input back into the test case prediction model to fine-tune the test case prediction model.
[0061] Figure 4 A flowchart illustrating the working principle of a test case prediction model according to an embodiment of the present disclosure is shown.
[0062] like Figure 4As shown, the test case prediction model includes a data preprocessing stage, a model training stage, a prediction stage, and a model optimization stage. Therefore, by manually optimizing the predicted values output by the test case prediction model and then using these optimized values as training data to fine-tune the model, the prediction capability and usability of the test case prediction model can be ensured.
[0063] Figure 5 A flowchart of a neural network-based test case generation method according to another embodiment of the present disclosure is shown.
[0064] like Figure 5 As shown, relevant documents from previous projects, including requirements documents, design documents, test cases, etc., are collected as raw data.
[0065] The raw data is preprocessed, and keywords are extracted. For example, word segmentation tools are used to segment words and construct a keyword set; test cases are labeled and processed step by step, and hot-coded to obtain a tag set; the keyword set and tag set are then merged to construct a training dataset.
[0066] Build a test case prediction model. The test case prediction model consists of a scene classifier and a process predictor. The scene classifier can be a deep learning model such as a convolutional neural network or its variants, while the process predictor can be a recurrent neural network or its variants. The scene classifier extracts scene classification features from the training dataset, and the process predictor uses... Figure 3 The method shown extracts test case step sequence information from the training dataset, integrates scenario classification features and test case step sequence information, and automatically generates predictive test cases.
[0067] Determine the loss function and set overfitting rules when training the test case prediction model using the training dataset to prevent overfitting during the training process.
[0068] The trained test case prediction model is used to predict test cases and obtain prediction results. The test case prediction results are manually corrected and used as training set to be fed back into the prediction model for fine-tuning, so as to ensure the predictive ability and usability of the test case prediction model.
[0069] The beneficial effects of the neural network-based test case generation method disclosed herein are as follows:
[0070] By combining machine learning technology with automated test case generation methods, this approach assists testers in their work, enabling rapid test case construction, significantly reducing test case writing time, and improving test scenario coverage. It also avoids missed tests and detections caused by human subjectivity, thus ensuring test quality. Addressing the issue of high time consumption in test case design during the R&D testing phase, it extracts features through parallel horizontal scenario classification and vertical process generation, improving scenario coverage while generating step-by-step test cases. The scenario classification module extracts scenario features, avoiding missed tests and detections caused by human subjectivity; the process generation module learns sequence information, providing the ability to generate step-by-step test cases, reducing human intervention, and allowing for the immediate use of predicted test cases.
[0071] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0072] Figure 6 A schematic diagram of a neural network-based test case generation apparatus according to an embodiment of the present disclosure is shown. Figure 6 As shown, the neural network-based test case generation device includes:
[0073] The collection module 601 is used to collect historical project documents and use the historical project documents as raw data.
[0074] Preprocessing module 602 is used to extract keywords and label test cases from the raw data to obtain a training dataset for building a test case prediction model;
[0075] The test case prediction module 603 is used to input the training dataset into the neural network-based test case prediction model and output predicted test cases.
[0076] The correction module 604 is used to manually intervene and correct the predicted test cases, and to input the corrected predicted test cases as a training dataset back into the test case prediction model to fine-tune the test case prediction model.
[0077] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0078] Figure 7 This is a schematic diagram of the structure of the electronic device 3 provided in an embodiment of this application. For example... Figure 7As shown, the electronic device 3 of this embodiment includes a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301. When the processor 301 executes the computer program 303, it implements the steps in the various method embodiments described above. Alternatively, when the processor 301 executes the computer program 303, it implements the functions of each module / unit in the various device embodiments described above.
[0079] For example, computer program 303 may be divided into one or more modules / units, which are stored in memory 302 and executed by processor 301 to complete this application. The one or more modules / units may be a series of computer program instruction segments capable of performing a specific function, which describe the execution process of computer program 303 in electronic device 3.
[0080] Electronic device 3 can be a desktop computer, laptop, handheld computer, cloud server, or other electronic device. Electronic device 3 may include, but is not limited to, processor 301 and memory 302. Those skilled in the art will understand that... Figure 3 This is merely an example of electronic device 3 and does not constitute a limitation on electronic device 3. It may include more or fewer components than shown, or combine certain components, or different components. For example, electronic device may also include input / output devices, network access devices, buses, etc.
[0081] Processor 301 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.
[0082] The memory 302 can be an internal storage unit of the electronic device 3, such as a hard disk or RAM. The memory 302 can also be an external storage device of the electronic device 3, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card. Furthermore, the memory 302 can include both internal and external storage units of the electronic device 3. The memory 302 is used to store computer programs and other programs and data required by the electronic device. The memory 302 can also be used to temporarily store data that has been output or will be output.
[0083] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0084] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0085] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments claimed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0086] In the embodiments provided in this application, it should be understood that the disclosed apparatus / computer devices and methods can be implemented in other ways. For example, the apparatus / computer device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, and the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0087] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0088] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0089] If an integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program may include computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electrical carrier signals and telecommunication signals.
[0090] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A test case generation method based on neural networks, characterized in that, The method includes: Collect historical project documents and use them as raw data; The original data is processed by keyword extraction and test case labeling to obtain a training dataset for building a test case prediction model; The training dataset is input into a neural network-based test case prediction model, which outputs predicted test cases. The predicted test cases are manually corrected, and the corrected predicted test cases are used as a training dataset to be back-input into the test case prediction model for fine-tuning. The test case prediction model includes a scenario classifier and a process predictor for test case feature extraction; The step of inputting the training dataset into a neural network-based test case prediction model and outputting predicted test cases includes: The scene classifier extracts scene classification features from the training dataset, and the process predictor extracts test case step sequence information from the training dataset. The scene classification features and the test case step sequence information are fused together to automatically generate predicted test cases. The scene classifier is a deep learning model based on a convolutional neural network; the process predictor is a process test case prediction model based on a recurrent neural network. The process predictor extracts test case step sequence information from the training dataset, including: The training dataset is input into a process predictor based on a recurrent neural network for learning, thereby obtaining the current sequence features of the test cases in the training dataset; The current sequence features of the test cases and the previous sequence memory features of the test cases are fused to obtain the timing information of the current sequence of the test cases, and the timing information of the current sequence of the test cases is saved to the memory unit of the process predictor. Repeat the above steps until the temporal characteristics of the test cases are extracted, and the test case step sequence information is obtained.
2. The test case generation method according to claim 1, characterized in that, The raw data includes requirements documents, design documents, and test cases.
3. The test case generation method according to claim 2, characterized in that, The step involves extracting keywords and labeling test cases from the raw data to obtain a training dataset for constructing a test case prediction model, including: Use word segmentation tools to extract keywords from requirements documents and design documents to obtain a keyword set; The test cases are tagged, broken down into steps, and hot-read encoded to obtain a test case tag set; The training dataset for the test case prediction model is constructed based on the keyword set and the test case tag set.
4. A test case generation device based on a neural network, characterized in that, The device includes: The collection module is used to collect historical project documents and use these historical project documents as raw data. The preprocessing module is used to extract keywords and label test cases from the raw data to obtain a training dataset for building a test case prediction model. The test case prediction module is used to input the training dataset into the neural network-based test case prediction model and output predicted test cases. The correction module is used to manually correct the predicted test cases and input the corrected predicted test cases as a training dataset back into the test case prediction model to fine-tune the test case prediction model. The test case prediction model includes a scenario classifier and a process predictor for test case feature extraction; The step of inputting the training dataset into a neural network-based test case prediction model and outputting predicted test cases includes: The scene classifier extracts scene classification features from the training dataset, and the process predictor extracts test case step sequence information from the training dataset. The scene classification features and the test case step sequence information are fused together to automatically generate predicted test cases. The scene classifier is a deep learning model based on a convolutional neural network; the process predictor is a process test case prediction model based on a recurrent neural network. The process predictor extracts test case step sequence information from the training dataset, including: The training dataset is input into a process predictor based on a recurrent neural network for learning, thereby obtaining the current sequence features of the test cases in the training dataset; The current sequence features of the test cases and the previous sequence memory features of the test cases are fused to obtain the timing information of the current sequence of the test cases, and the timing information of the current sequence of the test cases is saved to the memory unit of the process predictor. Repeat the above steps until the temporal characteristics of the test cases are extracted, and the test case step sequence information is obtained.
5. An electronic device, characterized in that, The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the method as described in any one of claims 1 to 3.
6. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Fuzzy test method based on neural network and computer readable storage medium
CN112463638A
XSS fuzzy test case generation method based on time convolutional network
CN114297079A