Software testing method and device, computer device, readable storage medium and program product
By employing a multi-stage training strategy and a multi-task model, the mapping between source code files and requirements design documents, as well as between requirements design documents and test documents, in software testing methodologies is enhanced. This resolves issues of incomplete and inconsistent mapping, thereby improving the accuracy and efficiency of software testing.
Patent Information
- Application Number
- CN202511574929.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-31
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2045-10-31
AI Technical Summary
In traditional software testing methods, the mapping between source code files and requirements design documents is incomplete, leading to missing or incorrect software functions; the mapping between requirements design documents and test documents is inconsistent, resulting in reduced software reliability and controllability; traditional methods are inefficient, inaccurate, and lack real-time performance in generating test documents.
A multi-stage training strategy is adopted to obtain a deep learning model. Through multi-task models and relation extraction models, the semantic association between entities is enhanced, thereby improving the quality of software testing.
It improves the accuracy and completeness of software testing, enhances the semantic relationships between entities, deeply explores the inherent requirements of test documents, and improves the quality and efficiency of test documents.
Smart Images

Figure CN121029629B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of software evaluation, in particular to a software testing method and device, computer equipment, readable storage medium and program product. BACKGROUND
[0002] In recent years, with the increase of the complexity of basic software functions, the traceability of software becomes more and more important, and the relationship between software source code, design documents and test documents plays a key role in ensuring software quality and functional integrity.
[0003] However, the traditional basic software evaluation process has the problem of low software test quality. SUMMARY
[0004] Therefore, it is necessary to provide a software testing method, device, computer equipment, readable storage medium and program product capable of improving software test quality.
[0005] In a first aspect, the present application provides a software testing method, comprising:
[0006] obtaining a deep learning model based on a multi-stage training strategy, the deep learning model being used for mapping test of source code files and requirement design documents; the multi-stage training strategy at least including pre-training, intermediate training and model adjustment;
[0007] obtaining a multi-task model based on the deep learning model, the multi-task model being used for mapping test of the requirement design documents and test documents;
[0008] optimizing the test documents based on a relationship extraction model; the optimization at least including enhancing semantic association between entities; the relationship extraction model at least including an encoding layer, an enhanced entity layer and a classification layer.
[0009] In one embodiment, the deep learning model is obtained based on a multi-stage training strategy, comprising:
[0010] pre-training the model based on unsupervised text data to obtain the deep learning model, the deep learning model including a general language representation;
[0011] adjusting the deep learning model to migrate the knowledge obtained by the deep learning model from the code search task to the mapping link task between the requirement design documents and the source code files.
[0012] In one of the embodiments, the adjusting of the deep learning model, the migration of the knowledge obtained by the deep learning model from the code search task to the mapping link task between the requirement design document and the source code file, comprises:
[0013] Intermediate training of the deep learning model for the code search problem, for enabling the deep learning model to identify the general principle of the correlation between natural language and programming language; the code search problem comprises obtaining the corresponding code segment based on the natural language description;
[0014] Based on the sample data of the associated source code file and the requirement design document, the knowledge obtained by the deep learning model from the intermediate training is migrated to the adjustment stage of the deep learning model, and the deep learning model is adjusted.
[0015] In one of the embodiments, the mapping test of the source code file and the requirement design document comprises:
[0016] The source code file and the requirement design document are decomposed and input to the deep learning model in turn;
[0017] The deep learning model determines whether there is an effective mapping link between the source code file and the requirement design document based on the feature conversion technology, and outputs the evaluation results.
[0018] In one of the embodiments, the obtaining of the multi-task model based on the deep learning model comprises:
[0019] The text sequence data of the cleaned and pretreated requirement design document and test document is input into the deep learning model to obtain the hidden representation of the text;
[0020] The hidden representation is used as a shared representation, and an independent output layer is designed for each task to obtain the multi-task model; each output layer comprises a fully connected layer and an activation function, and each output layer is connected with the shared representation;
[0021] The multi-task model is adjusted based on the associated data set of the requirement design document and the test document.
[0022] In one of the embodiments, the optimization of the test document based on the relation extraction model comprises:
[0023] The requirement design document is vectorized based on the encoding layer of the relation extraction model;
[0024] constructing a context representation of the entity based on an enhanced entity layer of the relation extraction model, and creating a final representation of the entity node;
[0025] performing entity type prediction based on a classification layer of the relation extraction model.
[0026] In a second aspect, the present application further provides a software testing device, comprising:
[0027] a multi-stage training module configured to obtain a deep learning model based on a multi-stage training strategy, the deep learning model being configured to perform mapping testing on a source code file and a requirement design document;
[0028] a multi-task model obtaining module configured to obtain a multi-task model based on the deep learning model, the multi-task model being configured to perform mapping testing on the requirement design document and a test document;
[0029] a test document optimization module configured to optimize the test document based on a relation extraction model, the optimization at least including enhancing semantic association between entities.
[0030] In a third aspect, the present application further provides a computer device, comprising a memory and a processor, the memory storing a computer program, and the processor implementing steps of the method of the first aspect when executing the computer program.
[0031] In a fourth aspect, the present application further provides a computer readable storage medium, which stores a computer program, and the computer program implements steps of the method of the first aspect when executed by a processor.
[0032] In a fifth aspect, the present application further provides a computer program product, comprising a computer program, and the computer program implements steps of the method of the first aspect when executed by a processor.
[0033] The above software testing method, device, computer device, readable storage medium and program product obtain a deep learning model based on a multi-stage training strategy, wherein the deep learning model is configured to perform mapping testing on a source code file and a requirement design document; obtain a multi-task model based on the deep learning model, wherein the multi-task model is configured to perform mapping testing on the requirement design document and a test document; and optimize the test document based on a relation extraction model, wherein the optimization at least includes enhancing semantic association between entities, thereby improving software testing quality. BRIEF DESCRIPTION OF DRAWINGS
[0034] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings needed to be used in the description of the embodiments of the present application or the related art. Obviously, the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other related drawings can also be obtained from these drawings without creative effort.
[0035] Figure 1 An application environment diagram of the software testing method in one embodiment;
[0036] Figure 2 A flowchart of the software testing method in one embodiment;
[0037] Figure 3 A detailed flowchart of the software testing method in one embodiment;
[0038] Figure 4 A flowchart of the deep learning model based on the multi-stage training strategy in one embodiment;
[0039] Figure 5 A diagram of the multi-neural network cooperation model in one embodiment;
[0040] Figure 6 A flowchart of the test document optimization based on the relation extraction model in one embodiment;
[0041] Figure 7 A structural block diagram of the software testing device in one embodiment;
[0042] Figure 8 An internal structure diagram of the computer device in one embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of the present application more clear, the following will further describe the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0044] The terms "include" and "have" and any variations thereof used in the present application are intended to cover the non-exclusive inclusion. The term "multiple" used in the present application refers to two and more than two. The term "and / or" used in the present application refers to one of the schemes, or any combination of multiple schemes.
[0045] Regarding the research on large model-based software testing technology, in recent years, with the increase in the complexity of basic software functions, the traceability of software becomes increasingly important, and the explicit relationship between software source code, design documents and test documents plays a key role in ensuring software quality and functional integrity. However, the traditional software testing has the following technical problems: the mapping between the source code file and the requirement design document is incomplete, resulting in the problem of missing or incorrect software functions; the mapping between the requirement design document and the test document is inconsistent, resulting in the problem of reduced software reliability and controllability; the traditional method has the problems of low efficiency, low accuracy and poor real-time performance in generating test documents.
[0046] Based on the above-mentioned traditional technology, the software testing method provided by the embodiments of the present application faces the requirements of the association consistency between the basic software source code, the requirement design document and the test document and the test case generation requirement, combines the large model technology, forms a large model-based software testing technology, and the technical roadmap is as shown in Figure 3 The software document intelligent review technology for testing is proposed, which breaks through the mapping enhancement technology of the source code file and the requirement design document based on the multi-stage training strategy, the requirement design document and the test document mapping enhancement technology based on the multi-neural network cooperation model, and the test document optimization technology based on the relationship extraction model, effectively enhances the semantic association between entities, and deeply mines the internal requirements of the test document.
[0047] Specifically, the embodiments of the present application provide a software testing method based on the association between the basic software source code, the requirement design document and the test document, and combine the large model technology to form a software document intelligent review technology for testing, as shown in Figure 3 First, the embodiments of the present application provide a mapping enhancement technology of the source code file and the requirement design document based on a multi-stage training strategy, introduce a pre-training large model and an enhanced learning mechanism, improve the mapping accuracy and completeness of the model, reduce the mapping deviation problem, and ensure the accuracy and completeness of the software functions. Secondly, the embodiments of the present application provide a requirement design document and test document mapping enhancement technology based on a multi-neural network cooperation model, which adopts a multi-task learning model to adapt to multi-level features, alleviates the problem of insufficient domain annotation corpus in entity relationship extraction, and can effectively extract the relationship between different entities when the data amount is small. Finally, the embodiments of the present application provide a test document optimization technology based on a relationship extraction model, which establishes a document graph structure, uses a self-attention mechanism and a neighboring point information aggregation technology to establish the relationship between entities, effectively enhances the semantic association between entities, and deeply mines the internal requirements of the test document.
[0048] It should be noted that the beneficial effects or technical problems solved by the embodiments of the present application are not limited to this, but also other implicit or related problems, which can be referred to the description of the following embodiments.
[0049] The technical solutions of the present application and how the technical solutions solve the above technical problems will be described in detail below with specific examples. The following specific examples can be combined with each other, and the same or similar concepts or processes can not be described again in some examples. The embodiments of the present application will be described below with reference to the accompanying drawings.
[0050] The software testing method provided by the embodiments of the present application can be applied to an application environment as shown in Figure 1 . The terminal 102 communicates with the server 104 through the network. The data storage system can store the data required to be processed by the server 104. The data storage system can be integrated on the server 104, or placed on the cloud or other network servers. The terminal 102 can be, but is not limited to, various personal computers, notebook computers, smart phones, tablet computers, unmanned aerial vehicles, low-altitude aircraft, Internet of Things devices, and portable wearable devices. The Internet of Things device can be a smart speaker, a smart television, a smart air conditioner, a smart vehicle device, a projection device, etc. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, etc. The head-mounted device can be a virtual reality (VR) device, an augmented reality (AR) device, smart glasses, etc. The server 104 can be a standalone physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services.
[0051] In an exemplary embodiment, as shown in Figure 2 , a software testing method is provided. Taking the terminal 102 or the server 104 in Figure 1 as an example, the method includes the following steps 202 to 206. Wherein:
[0052] Step 202, obtaining a deep learning model based on a multi-stage training strategy, the deep learning model is used for mapping test on the source code file and the requirement design document; the multi-stage training strategy at least includes pre-training, intermediate training and model adjustment.
[0053] Specifically, the deep learning model is obtained based on the multi-stage training strategy, wherein the deep learning model is used for mapping test on the source code file and the requirement design document.
[0054] Exemplarily, as shown in Figure 3As shown, the embodiment of the present application proposes a semantic correlation algorithm based on a deep learning multi-stage training strategy. First, rich semantic features are obtained on a large-scale pre-trained deep learning model, and then adjusted on the mapping task of the file to adapt to the specific semantic structure of the source code and the requirement design document, thereby solving the problem of incomplete mapping between the source code file and the requirement design document, resulting in missing or incorrect software functions.
[0055] Step 204, obtaining a multi-task model based on a deep learning model, the multi-task model being used for mapping test of the requirement design document and the test document.
[0056] The multi-task model can refer to a multi-neural network cooperation model, and can also be referred to as a multi-task learning model.
[0057] Specifically, a multi-task model is obtained based on a deep learning model, wherein the multi-task model is used for mapping test of the requirement design document and the test document.
[0058] Exemplarily, as shown in the figure, Figure 3 As shown, the embodiment of the present application proposes an entity information extraction algorithm based on a multi-neural network cooperation model. By using a pre-trained deep learning model to learn the semantic information implied by the sample, the relationship extraction capability of the model is improved, thereby solving the problem of inconsistent mapping between the requirement design document and the test document, resulting in reduced software reliability and controllability.
[0059] Step 206, based on the relationship extraction model, optimizing the test document; the optimization at least includes enhancing the semantic correlation between entities; the relationship extraction model at least includes an encoding layer, an enhanced entity layer and a classification layer.
[0060] Specifically, the test document is optimized based on the relationship extraction model, wherein the optimization of the test document at least includes enhancing the semantic correlation between entities in the test document.
[0061] Exemplarily, as shown in the figure, Figure 3 As shown, the embodiment of the present application proposes a document-level relationship extraction model based on enhanced entity representation. A deep learning model is used to construct a basic requirement design document graph structure, and a graph neural network propagation mechanism is used to aggregate the information of adjacent points. The sentence context and theme information related to entity relationship prediction are integrated into the entity node representation of the basic document graph, thereby obtaining enhanced entity node representation and improving the quality of the test document. Thus, the problems of low efficiency, low accuracy and poor real-time performance of the test document generated by the traditional method are solved.
[0062] In the above software testing method, the mapping test of the source code file and the requirement design document is performed by a deep learning model based on a multi-stage training strategy, that is, a pre-training large model with a multi-stage training strategy and a reinforcement learning mechanism are introduced to improve the mapping accuracy and integrity of the deep learning model, reduce the mapping deviation problem, and ensure the accuracy and integrity of the software function. Secondly, the mapping test of the requirement design document and the test document is performed based on a multi-neural network cooperation model, a multi-task learning model is used to adapt to multi-level features, the problem of insufficient domain annotation corpus in entity relationship extraction is alleviated, and the relationship between different entities can be effectively extracted even when the data amount is small. Finally, the test document optimization technology based on the relationship extraction model is used to establish the relationship between entities by establishing a document graph structure, using a self-attention mechanism and a neighboring point information aggregation technology, effectively enhancing the semantic association between entities, and deeply mining the internal requirements of the test document.
[0063] In an exemplary embodiment, a deep learning model is obtained based on a multi-stage training strategy, including:
[0064] The model is pre-trained based on unsupervised text data to obtain a deep learning model, and the deep learning model includes a general language representation.
[0065] The deep learning model is adjusted to transfer the knowledge obtained by the deep learning model from a code search task to a mapping link task between a requirement design document and a source code file.
[0066] The unsupervised text data can refer to code library data, and the embodiments of the present application are not limited thereto; the deep learning model has strong semantic recognition capability and flexible transfer learning capability, and can effectively bridge the semantic difference between the source code and the requirement design document; the deep learning model can be referred to as a model.
[0067] Specifically, the model is pre-trained based on unsupervised text data to obtain a deep learning model, and the deep learning model includes a general language representation; the deep learning model is adjusted to transfer the knowledge obtained by the deep learning model from a code search task to a mapping link task between a requirement design document and a source code file.
[0068] Exemplarily, the embodiments of the present application adopt a mapping enhancement method for a source code file and a requirement design document based on a multi-stage training strategy, as shown in Figure 4The deep learning model has strong semantic recognition ability and flexible transfer learning ability, which can effectively bridge the semantic difference between source code and requirement design documents. This project plans to use a three-stage training strategy based on a deep learning model to gradually enhance the mapping relationship using pre-training, intermediate training, and adjustment methods. First, pre-train the model on a large amount of unsupervised text data to obtain a general language representation. Then, adjust the knowledge obtained from the data-rich code search task to the mapping link task between requirement design documents and source code files. Unsupervised learning allows the effective deployment of deep learning models in environments with sparse multi-source document data for basic software, effectively alleviating the problem of sparse mapping file data.
[0069] Optionally, the model pre-training is performed on a large amount of code library data (such as the CodeSearchNet dataset), and the main purpose is to let the model learn the lexical distribution and semantic relationship between natural language documents and programming language documents. By using the Masked Language Modeling (MLM) method, some words in the input text are randomly masked, and then the model is trained to predict these masked words, thereby capturing deep language features and patterns. For example, Figure 4 As shown, the pre-training process includes obtaining the model through training data (functions).
[0070] In an exemplary embodiment, the deep learning model is adjusted to transfer the knowledge obtained by the deep learning model from the code search task to the deep learning model for the mapping link task between the requirement design document and the source code file, including:
[0071] The intermediate training of the deep learning model is performed for the code search problem, which is used to enable the deep learning model to identify the general principles of the correlation between natural language and programming language; the code search problem includes obtaining the corresponding code snippet based on the natural language description;
[0072] Based on the sample data of the associated source code file and the requirement design document, the knowledge obtained by the deep learning model from the intermediate training is transferred to the adjustment stage of the deep learning model, and the deep learning model is adjusted.
[0073] In particular, in the intermediate training, the deep learning model is trained for the code search problem, which involves retrieving a corresponding code snippet (e.g., a function definition) using a natural language description (e.g., a function's docstring). By utilizing a labeled dataset, the model is trained to learn general rules that discriminate the correlation between natural language and programming language. This stage is set as a binary classification problem, and the model needs to determine whether a given docstring accurately describes the corresponding function. A balanced training set containing an equal number of positive and negative samples is constructed, and a dynamic random negative sampling strategy is adopted to update the training set at the beginning of each training cycle, including all function and docstring pairs, to ensure that the model can learn from previously unseen negative samples. At the same time, an enhanced learning mechanism is adopted to improve the performance of mapping prediction through continuous feedback, thereby improving the accuracy of mapping.
[0074] Optionally, as shown in Figure 4 , in the intermediate training, the pre-trained model is used to form a correlation classifier, and the pre-trained training data (functions) and corresponding specification documents are used to train the model for the code search problem, and then knowledge transfer forms a new correlation classifier.
[0075] In the adjustment of the deep learning model, as shown in Figure 4 , the sample data of the associated source code and requirement design documents (i.e., the functions in Figure 4 and the requirements) are used. Only a small amount of manually labeled data is required in this process, and the knowledge obtained in the intermediate training stage is effectively transferred to the adjustment stage, so that the model can achieve effective classification performance in downstream tasks with only a small amount of labeled data. The training in the adjustment stage also adopts a similar binary classification method to evaluate the model's ability to distinguish between relevant and irrelevant mappings. In addition, by applying a dynamic random negative sampling strategy, the model's ability to identify difficult negative samples is enhanced, which helps to improve the model's generalization ability and avoid overfitting too early.
[0076] In an exemplary embodiment, the mapping test of the source code file and the requirement design document includes:
[0077] The source code file and the requirement design document are decomposed and input into the deep learning model in turn;
[0078] The deep learning model determines whether there is an effective mapping link between the source code file and the requirement design document based on feature conversion technology, and outputs the evaluation results.
[0079] Among them, the mapping test can also refer to the model inference of the deep learning model.
[0080] Specifically, when performing model inference, the source code is functionally segmented, and the requirement design document is decomposed into individual requirement units. Each source code segment and the corresponding requirement design document segment is input into the model in turn, and by comparing each requirement in the requirement design document with the similarity of each part of the source code, it is determined whether there is an effective mapping link, and the evaluation results are output. In addition, in order to improve the accuracy of inference, the model uses feature conversion techniques learned during the training phase, such as text embedding and context analysis, when processing input data, to ensure a deep understanding of the semantic relationship between requirements and code.
[0081] In an exemplary embodiment, a multi-task model is obtained based on a deep learning model, comprising:
[0082] Input the text sequence data of the cleaned and preprocessed requirement design document and test document into the deep learning model to obtain the hidden representation of the text;
[0083] The hidden representation is used as a shared representation, and an independent output layer is designed for each task to obtain a multi-task model; wherein each output layer includes a fully connected layer and an activation function, and each output layer is connected to the shared representation;
[0084] Adjust the multi-task model based on the association data set of the requirement design document and the test document.
[0085] Among them, the requirement design document and the test document play a key role in ensuring software quality and functional integrity. The requirement design document usually describes the architecture, module design, data flow and other details of the software system, and is the guidance for developers when implementing software functions. The test document contains the plan, method, and use case of software testing, which is used to verify the correctness and stability of the software under different conditions. There is a close relationship between the design document and the test document, and they complement each other. The requirement description and design scheme in the requirement design document will directly affect the test case design and execution in the test document, so the mapping relationship between the requirement design document and the test document is crucial. By intelligently reviewing the mapping relationship between the design document and the test document, the development team can better understand the relationship between requirements, design, and testing, thereby improving the efficiency and quality of software development.
[0086] Specifically, the embodiment of the present application adopts a requirement design document and test document mapping enhancement method based on a multi-neural network cooperation model, realizes intelligent review of the mapping relationship between the design document and the test document, and one of the most critical technologies is information extraction. The goal of information extraction is to identify entities and events in the text and their related connections, extract specific information from structured or semi-structured natural language text, and organize it into a structured form. However, since the entities are scattered in the text, it is impossible to determine the possible relationship between the entities, nor can it be summarized as structured information, so it is necessary to use entity relationship extraction technology to determine the relationship between the entities in the text and structure the extracted data. The mapping enhancement method of the embodiment of the present application effectively extracts unit features from the target entity pair by using deep learning model, semantic role embedding, entity attention and multi-task learning, and combines them into fusion features, thereby capturing abstract semantics and sentence structure.
[0087] In which, the multi-task learning combines multiple deep learning models into a multi-task model, for example Figure 5 As shown, there are multiple input layers and parameter sharing layers connected, Figure 5 The A layer, the B layer and the C layer and their corresponding output layers correspond to the simultaneous execution of task A, task B and task C. Each task has an independent branch, which is used to capture local patterns, extract global context and identify word relationships, and the low layer shares the representation. By integrating the captured local and global context, the model learns more supervised information, thereby improving the effectiveness of entity relationship extraction.
[0088] Exemplarily, the specific steps of the embodiment of the present application can be as follows:
[0089] First, create a high-dimensional vector representation of the text. The text sequence data of the cleaned and preprocessed requirement design document and test document is input into the deep learning model. Load the model pre-training weight to encode the text sequence of the requirement design document and the test document. This step will generate a hidden representation of the text, which maps the text sequence to a high-dimensional vector representation.
[0090] Second, multi-task learning. The hidden representation generated by the deep learning model is used as a shared representation, i.e. Figure 5 The parameter sharing layer in the above formula is used for multi-task learning, which ensures that the text representation learned by the model is consistent for all tasks. Design an independent output layer for each task, and each output layer should include a fully connected layer and an activation function. The output layer of each task should be connected to the shared representation of the deep learning model in order to simultaneously learn and optimize multiple tasks. At the same time, a comprehensive loss function is customized, which is weighted for different tasks, so that during the training process, the model can balance and associate different tasks.
[0091] Finally, model adjustment, which can also be referred to as model fine-tuning. Adjust the part of the layers of the model using the small requirement design document associated with the test document dataset to adapt to the requirements of specific tasks, improve the performance and generalization ability of the model.
[0092] In an exemplary embodiment, based on the relationship extraction model, the test document is optimized, including:
[0093] Based on the encoding layer of the relationship extraction model, the requirement design document is represented as a vector;
[0094] Based on the enhanced entity layer of the relationship extraction model, the context representation of the entity is constructed, and the final representation of the entity node is created;
[0095] Based on the classification layer of the relationship extraction model, the entity type prediction is performed.
[0096] Among them, the test document plays a crucial role in the software development process, which records the functional requirements, test plans, test cases, test results and other information of the software system, which helps to ensure software quality, improve development efficiency and reduce maintenance cost. In the development environment where software requirements change frequently and iteration speed is fast, the real-time requirement of test document is high, and it needs to be updated and iterated constantly. If the test document information is not updated in time, and the outdated document is used for testing, it will affect the testing effect of the software. With the development of artificial intelligence technology, generative technology has shown great potential in the field of test document enhancement and optimization. Generative technology can realize the dynamic update and real-time generation of documents, and can maintain the consistency of the document with the actual software implementation. When the software requirements or functions change, generative technology can quickly update the document to ensure that the team always uses the latest document for testing, improving the testing effect and reliability. However, the use of generative technology to optimize test documents often faces the problem of long-distance dependency between entity nodes. Long-distance dependency makes it difficult for the model to effectively capture long-distance entity relationships, increasing the training complexity and computational cost, resulting in a lack of logic and coherence in the generated text. These problems limit the application of generative models in test document optimization.
[0097] Specifically, the embodiment of the present application adopts a test document optimization method based on an enhanced entity representation document-level relationship extraction model, as shown in Figure 6As shown, aiming to further optimize the quality of test documents. The whole model contains 3 parts, namely the encoding layer, the enhanced entity representation layer and the classification layer. In the encoding layer, the input document is encoded by using a pre-trained model. The enhanced entity representation layer is the core of the model, in order to improve the ability of intra-sentence relation extraction, the sentence context representation is added to the entity representation. In order to enhance the inter-sentence reasoning ability, the document theme information representation is added to the constructed entity representation, so that the final representation of the entity is composed of the entity representation itself, the sentence context representation and the document theme information representation. Then the information of adjacent nodes is aggregated to further enhance the representation ability of the entity node, and the bilinear function is used in the classification layer to classify the entity pair.
[0098] Optionally, as Figure 6 shown, the specific steps of the embodiments of the application can be as follows:
[0099] First, data vectorization is performed. Each word in the requirement design document is mapped into a vector, and the embedding representation of the word is connected with the corresponding entity type embedding representation, and then the embedding representation of each word is sent to the model encoder to obtain the final vectorization representation of each word, that is Figure 6 word embedding and entity type embedding shown in
[0100] Then, the entity context representation is constructed. The document graph is constructed, including entity nodes and edges between entities. The self-attention mechanism is used to assign higher weights to information that has greater influence on the entity, and lower weights to information that has less influence on the entity. The context representation of the sentence is formed by aggregating different words in the sentence, that is Figure 6 sentence context representation and document theme representation based on the model and sentences 1, 2, 3, etc. shown in
[0101] Create the final representation of the entity node. The representation of the entity node is connected with the representation of the sentence in which it is located and the document theme information representation, so that the entity representation has the information of the two, and has the ability of intra-sentence and inter-sentence reasoning. The convolutional network is used to aggregate the information of the neighbor nodes, and the final representation of the entity node is obtained after connection, that is Figure 6 entity itself representation in
[0102] Finally, the entity type prediction is performed. After multiple network aggregations, the representation of all entity nodes can be obtained. Then the sigmoid function is used to calculate the probability of each relationship type of the entity pair, that is Figure 6 entity classification and relationship type calculation based on the convolutional network in
[0103] It should be understood that although each step in the flowchart involved in the above embodiments is shown in sequence according to the direction of the arrow, these steps are not necessarily executed in the order indicated by the arrow. Unless otherwise specified herein, there is no strict order limitation for the execution of these steps, and these steps can be executed in other orders. Moreover, at least part of the steps in the flowchart involved in the above embodiments can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps. It can be understood that the steps in different embodiments can be freely combined as needed, and various non-contradictory schemes formed by the combination are within the scope of protection of the present application.
[0104] Based on the same inventive concept, the embodiments of the present application also provide a software testing device for implementing the above-mentioned software testing method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme described in the above method, so the specific limitations in one or more software testing device embodiments provided below can refer to the limitations of the software testing method in the above text, which will not be repeated here.
[0105] In one exemplary embodiment, as shown in Figure 7 A software testing device 900 is provided, comprising a multi-stage training module 901, a multi-task model acquisition module 902, and a test document optimization module 903, wherein:
[0106] The multi-stage training module 901 is configured to obtain a deep learning model based on a multi-stage training strategy, and the deep learning model is configured to perform mapping test on the source code file and the requirement design document;
[0107] The multi-task model acquisition module 902 is configured to obtain a multi-task model based on the deep learning model, and the multi-task model is configured to perform mapping test on the requirement design document and the test document;
[0108] The test document optimization module 903 is configured to optimize the test document based on the relationship extraction model; the optimization at least includes enhancing the semantic association between entities.
[0109] In one embodiment, the multi-stage training module 901 is further configured to pre-train the model based on unsupervised text data to obtain a deep learning model, and the deep learning model includes a general language representation; and the deep learning model is adjusted to migrate the knowledge obtained by the deep learning model from the code search task to the mapping link task between the requirement design document and the source code file.
[0110] In one of the embodiments, the multi-stage training module 901 is further configured to perform intermediate training of the deep learning model for a code search problem, so as to enable the deep learning model to identify general principles of correlation between natural language and programming language; the code search problem includes obtaining a corresponding code snippet based on a natural language description; based on sample data of associated source code files and requirement design documents, the deep learning model migrates knowledge obtained from the intermediate training to an adjustment, i.e., a fine-tuning stage, of the deep learning model, and fine-tunes the deep learning model.
[0111] In one of the embodiments, the multi-stage training module 901 is further configured to decompose the source code files and the requirement design documents, and input them to the deep learning model in sequence; the deep learning model determines whether there is an effective mapping link between the source code files and the requirement design documents based on a feature conversion technology, and outputs an evaluation result.
[0112] In one of the embodiments, the multi-task model obtaining module 902 is further configured to input the text sequence data of the cleaned and preprocessed requirement design documents and test documents to the deep learning model, to obtain hidden representations of the texts; take the hidden representations as shared representations, to design independent output layers for each task, to obtain a multi-task model; each output layer includes a full connection layer and an activation function, and each output layer is connected with the shared representations; and adjust the multi-task model based on an associated data set of the requirement design documents and the test documents.
[0113] In one of the embodiments, the test document optimization module 903 is further configured to perform vectorization representation of the requirement design documents based on an encoding layer of the relation extraction model; construct context representation of entities and create final representation of entity nodes based on an enhanced entity layer of the relation extraction model; and perform entity type prediction based on a classification layer of the relation extraction model.
[0114] The above software testing apparatus can be implemented by software, hardware, or a combination thereof. The above modules can be embedded in or independent of a processor in a computer device in a hardware form, or stored in a memory in a computer device in a software form, so as to be called and executed by a processor to perform operations corresponding to the above modules.
[0115] In one of the embodiments, a computer device is provided, which can be a server, and an internal structure diagram of the computer device can be as shown in FIG. 8. Figure 8As shown in the figure. The computer device includes a processor, a memory, an input / output interface (I / O for short) and a communication interface. Among them, the processor, the memory and the input / output interface are connected through the system bus, and the communication interface is connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capability. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The database of the computer device is used to store software test data. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals through network connection. The computer program is executed by the processor to implement a software testing method.
[0116] Those skilled in the art can understand that, Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or fewer components than those shown in the figure, or combine certain components, or have a different component arrangement.
[0117] In one exemplary embodiment, a computer device is provided, including a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps shown in the above method.
[0118] In one embodiment, a computer readable storage medium is provided, which stores a computer program, and the computer program is executed by the processor to implement the steps shown in the above method.
[0119] In one embodiment, a computer program product is provided, including a computer program, and the computer program is executed by the processor to implement the steps shown in the above method.
[0120] It should be noted that the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in the present application are all information and data authorized by the user or authorized by all parties, and the collection, use and processing of related data need to comply with relevant regulations.
[0121] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by a computer program instructing relevant hardware. The computer program can be stored in a non-volatile computer readable storage medium. When the computer program is executed, the processes of the above-mentioned embodiment methods can be included. Any reference to memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. The non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical storage, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. The volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration but not limitation, the RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The database involved in the embodiments provided in the present application can include at least one of a relational database and a non-relational database. The non-relational database can include a distributed database based on a block chain, etc., but is not limited thereto. The processor involved in the embodiments provided in the present application can be a general processor, a central processing unit, a graphics processing unit, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but is not limited thereto.
[0122] The technical features of the above embodiments can be combined arbitrarily. In order to make the description simple, all possible combinations of the technical features in the above embodiments are not described, however, as long as the combinations of the technical features do not exist contradictory, it should be considered as the scope of the present application.
[0123] The above embodiments only express several implementation ways of the present application, and the description is specific and detailed, but it should not be understood as a limitation to the patent scope of the present application. It should be pointed out that for ordinary skilled in the art, without departing from the concept of the present application, several modifications and improvements can be made, which all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.
Claims
1. A software testing method, characterized in that, The method includes: A deep learning model is obtained based on a multi-stage training strategy. The deep learning model is used to perform mapping tests between source code files and requirement design documents. The multi-stage training strategy includes at least pre-training, intermediate training, and model tuning. A multi-task model is obtained based on the deep learning model, and the multi-task model is used to perform mapping tests on the requirement design document and the test document. The test document is optimized based on a relation extraction model; the optimization includes at least enhancing the semantic relationships between entities; the relation extraction model includes at least an encoding layer, an enhanced entity layer, and a classification layer. The mapping test between the source code file and the requirements design document includes: The source code file and the requirements design document are decomposed and then sequentially input into the deep learning model; The deep learning model, based on feature transformation technology, determines whether there is a valid mapping link between the source code file and the requirement design document, and summarizes and outputs the evaluation results. The process of obtaining a multi-task model based on the deep learning model includes: The cleaned and preprocessed text sequence data of the requirement design document and the test document are input into the deep learning model to obtain the hidden representation of the text; The hidden representation is used as a shared representation, and independent output layers are designed for each task to obtain the multi-task model; wherein each output layer includes a fully connected layer and an activation function, and each output layer is connected to the shared representation; The multi-task model is adjusted based on the associated dataset of the requirements design document and the test document.
2. The method according to claim 1, characterized in that, The method for obtaining a deep learning model based on a multi-stage training strategy includes: The deep learning model is obtained by pre-training the model based on unsupervised text data, and the deep learning model includes a general language representation. The deep learning model is adjusted to transfer the knowledge obtained by the deep learning model from the code search task to the mapping and linking task between the requirement design document and the source code file.
3. The method according to claim 2, characterized in that, The adjustment of the deep learning model, transferring the knowledge obtained by the deep learning model from the code search task to the mapping and linking task between the requirements design document and the source code file, includes: Intermediate training is performed on the deep learning model for the code search problem to enable the deep learning model to identify the general principles of correlation between natural language and programming language; the code search problem includes obtaining corresponding code snippets based on natural language descriptions; Based on the sample data of the associated source code files and the requirements design documents, the knowledge acquired by the deep learning model from the intermediate training is transferred to the adjustment stage of the deep learning model, and the deep learning model is adjusted.
4. The method according to claim 1, characterized in that, The optimization of the test document based on the relation extraction model includes: Based on the encoding layer of the relation extraction model, the requirement design document is vectorized. Based on the enhanced entity layer of the relation extraction model, a contextual representation of the entity is constructed, and the final representation of the entity node is created. Based on the classification layer of the aforementioned relation extraction model, entity type prediction is performed.
5. A software testing apparatus, characterized in that, The device includes: A multi-stage training module is used to obtain a deep learning model based on a multi-stage training strategy. The deep learning model is used to perform mapping tests between source code files and requirement design documents. A multi-task model acquisition module is used to acquire a multi-task model based on the deep learning model, and the multi-task model is used to perform mapping tests on the requirement design document and the test document. The test document optimization module is used to optimize the test document based on the relation extraction model; the optimization includes at least enhancing the semantic association between entities. The multi-stage training module is also used to decompose the source code file and the requirement design document, and input them sequentially into the deep learning model; the deep learning model, based on feature transformation technology, determines whether there is a valid mapping link between the source code file and the requirement design document, and summarizes and outputs the evaluation results; The multi-task model acquisition module is further configured to input the cleaned and preprocessed text sequence data of the requirement design document and the test document into the deep learning model to obtain the hidden representation of the text; use the hidden representation as a shared representation to design independent output layers for each task to obtain the multi-task model; wherein each output layer includes a fully connected layer and an activation function, and each output layer is connected to the shared representation; and adjust the multi-task model based on the associated dataset of the requirement design document and the test document.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.
Citation Information
Patent Citations
Method for enhancing classification-based software demand tracking link recovery through knowledge learning and electronic device
CN113011461A
Test case generation method and system based on large model and retrieval enhancement generation
CN119537222A
Document-level relation extraction method based on multi-task learning and knowledge distillation
CN119761495A