Test method, device, electronic device, and storage medium
By using pre-trained machine learning models to automatically determine test cases and functional modules in the software development process, the problems of low testing efficiency and omissions caused by manual judgment are solved, and a highly efficient testing process is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SPREADTRUM COMMUNICATION (SHANGHAI) CO LTD
- Filing Date
- 2026-03-04
- Publication Date
- 2026-06-09
AI Technical Summary
In the software development process, the determination of test cases and functional modules relies on manual judgment, which leads to low testing efficiency and easy omission of key test points.
By automatically identifying the target functional modules and test cases corresponding to the defects and bugs to be tested based on pre-trained machine learning models, and using logistic regression and random forest models to quickly recommend test cases and functional modules without GPU resources.
It improves testing efficiency and reliability, reduces manual intervention, and enables rapid and accurate test case and functional module recommendations.
Smart Images

Figure CN122173398A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software testing technology, and in particular to a testing method, apparatus, electronic device and storage medium. Background Technology
[0002] In the software development process, each version update is usually accompanied by a large number of code modifications (such as bug fixes, new features, or refactoring). Testers need to quickly identify test cases and functional modules related to code changes to ensure comprehensive test coverage.
[0003] During the testing process, the determination of test cases and functional modules largely relies on manual judgment, which results in low testing efficiency and makes it easy to miss key test points. Summary of the Invention
[0004] This application provides a testing method, apparatus, electronic device, and storage medium that can improve testing efficiency.
[0005] In a first aspect, embodiments of this application provide a testing method, including:
[0006] Based on the test data, determine the file data corresponding to at least one defect / bug to be tested;
[0007] The file data corresponding to the bug to be tested is input into the pre-trained first model to obtain the target functional module corresponding to the bug to be tested;
[0008] The file data corresponding to the bug to be tested is input into the pre-trained second model to obtain the target test cases corresponding to the bug to be tested;
[0009] The bug to be tested is performed based on the target functional module and the target test case.
[0010] In some embodiments, the method further includes:
[0011] Training data is determined based on historical test data, the first historical code path data of the historical test data, and test case result data.
[0012] The initial first model is trained based on the training data to obtain the pre-trained first model;
[0013] The initial second model is trained based on the training data to obtain the pre-trained second model.
[0014] In some embodiments, determining the training data based on historical test data, first historical code path data of the historical test data, and test case result data includes:
[0015] Based on the historical test data and the first historical code path data, a first mapping data is determined between the first historical functional module corresponding to the historical test data and the first historical code path data, and a second mapping data is determined between the first historical test case corresponding to the historical test data and the first historical code path data.
[0016] Based on the test case result data, determine the historical test bugs and the corresponding second historical test cases, second historical functional modules, and second historical code path data. Determine the third mapping data between the second historical functional modules and the second historical code path data, as well as the fourth mapping data between the second historical test cases and the second historical code path data.
[0017] The training data is determined based on the first mapping data, the third mapping data, the first historical test cases, the first historical functional modules, the first historical code paths, the second historical test cases, the second historical functional modules, and the second historical code paths.
[0018] In some embodiments, determining the training data based on the first mapping data, the third mapping data, the first historical test case, the first historical functional module, the first historical code path, the second historical test case, the second historical functional module, and the second historical code path includes:
[0019] Based on the first mapping data, the third mapping data is deduplicated to obtain the deduplicated third mapping data.
[0020] The deduplicated third mapping data, along with the first mapping data, the second mapping data, and the third mapping data, are determined as the training data.
[0021] In some embodiments, training an initial first model based on the training data to obtain the pre-trained first model includes:
[0022] Determine the historical functional module labels of the training data;
[0023] The initial first model is trained based on the training data and the historical functional module labels to obtain the pre-trained first model.
[0024] In some embodiments, training the initial second model based on the training data to obtain the pre-trained second model includes:
[0025] Determine the historical test case labels of the training data;
[0026] The initial second model is trained based on the training data and the historical test case labels to obtain the pre-trained second model.
[0027] Secondly, embodiments of this application provide a testing apparatus, comprising:
[0028] The file data determination module is used to determine the file data corresponding to at least one defect or bug to be tested based on the test data.
[0029] The first prediction module is used to input the file data corresponding to the bug to be tested into the pre-trained first model to obtain the target functional module corresponding to the bug to be tested.
[0030] The second prediction module is used to input the file data corresponding to the bug to be tested into the pre-trained second model to obtain the target test cases corresponding to the bug to be tested;
[0031] The testing module is used to test the bug to be tested based on the target functional module and the target test cases.
[0032] Thirdly, embodiments of this application provide an electronic device, including: a memory and a processor;
[0033] The memory stores computer-executed instructions;
[0034] The processor executes computer execution instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0035] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.
[0036] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.
[0037] In a sixth aspect, embodiments of this application provide a chip, the chip including at least one processor, the processor being configured to execute program instructions to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0038] The testing method, apparatus, electronic device, and storage medium in this application embodiment analyze the data to be tested during testing to determine one or more bugs to be tested, as well as the file data of the bugs to be tested. By inputting the file data into a pre-trained first model and a pre-trained second model respectively, the target functional module and target test cases of the bugs to be tested are obtained accordingly. In this way, the target functional module and target test cases can be obtained without human intervention. Subsequently, the bugs to be tested can be tested based on the target functional module and target test cases output by the pre-trained first model and the pre-trained second model, thereby improving the efficiency and reliability of testing. Attached Figure Description
[0039] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0040] Figure 1 An implementation scenario diagram of the testing method provided in this application;
[0041] Figure 2 Flowchart of the test method provided in this application Figure 1 ;
[0042] Figure 3 Flowchart of the test method provided in this application Figure 2 ;
[0043] Figure 4 A schematic diagram of the training process for the initial first model provided in this application;
[0044] Figure 5 A schematic diagram of the training process for the initial second model provided in this application;
[0045] Figure 6 A schematic diagram of the test apparatus provided in this application;
[0046] Figure 7 A schematic diagram of the structure of the electronic device provided in this application.
[0047] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0048] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0049] In some testing processes, the original precise test recommendation method can be used to determine test cases and functional modules. This original precise test recommendation uses a training dataset provided by testers based on their experience, and uses a simple logistic regression method for training and learning. Finally, it recommends which module to modify based on the version change item file. However, this method has a small amount of training data, low recommendation accuracy, and cannot recommend test cases that can cover the change items.
[0050] In other testing processes, typical test case data is collected from previous test projects to build and maintain a typical test case library. Then, test case models generated by natural language processing, intelligent word segmentation, and identifier extraction are used to intelligently recommend test case data that best suits the test requirements and functions for testers. However, natural language processing methods often require graphics processing unit (GPU) hardware resources. Without GPU hardware resources, the training and testing process for a large amount of training data takes a long time, making it impossible to obtain recommendation results in a very short time.
[0051] This application provides a testing method, apparatus, electronic device, and storage medium. This process can determine test cases and functional modules without the need for GPUs or human intervention, thereby improving testing efficiency.
[0052] like Figure 1 The implementation scenario diagram provided in this application shows that the test system corresponding to this implementation scenario includes a client 10 and a server 11, which are connected via network communication.
[0053] The execution entity of the method in this application embodiment is the server 11. The client 10 can receive the test data and send the test data to the server 11 through the network. The server 11 performs the test and can feed back the test results or target functional modules and target test cases to the client 10 through the network. The client 10 has a graphical user interface, in which the test results or target functional modules and target test cases can be displayed.
[0054] In some embodiments, after receiving the test data, the server 11 determines the file data corresponding to at least one defect bug to be tested based on the test data; inputs the file data corresponding to the bug to be tested into a pre-trained first model to obtain the target functional module corresponding to the bug to be tested; inputs the file data corresponding to the bug to be tested into a pre-trained second model to obtain the target test case corresponding to the bug to be tested; and performs testing on the bug to be tested based on the target functional module and the target test case.
[0055] In some embodiments, the server 11 is provided with a pre-trained first model and a pre-trained second model.
[0056] Understandably, the testing equipment can be set up in Figure 1 In server 11, but as shown in this embodiment... Figure 1 The implementation environment shown is merely exemplary. In other embodiments, the test data marking method can also be applied to other implementation environments, and the test data marking device can also be set in other structures in other implementation environments. No specific limitations are made here.
[0057] In this embodiment, the client 10 is an electronic device on the user side, which can be a wired terminal with a visual structure or a wireless terminal. In other embodiments, the terminal can be an electronic device with a visual structure, such as a mobile phone, computer, tablet, or vehicle-mounted device.
[0058] Server 11 can be an edge environment or a cloud environment, such as a physical server, server cluster, or cloud server, etc., without specific restrictions.
[0059] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0060] Figure 2 Flowchart of the test method provided in this application Figure 1 ,like Figure 2 As shown, the method includes:
[0061] S201. Based on the test data, determine the file data corresponding to at least one bug to be tested.
[0062] In some embodiments, the data to be tested is code data that needs to be changed.
[0063] In some embodiments, when a pre-trained first model and a pre-trained second model are obtained, the server detects a version change and automatically obtains version-related code change data, i.e., the data to be tested.
[0064] In some embodiments, the data to be tested can be considered as merged bug data.
[0065] In some embodiments, the data to be tested may be code change data corresponding to one or more bugs to be tested.
[0066] In some embodiments, bugs with merged code are captured based on the test data, and the test bugs are processed to generate bug numbers and file data corresponding to each test bug.
[0067] This file contains the filenames of the bugs to be tested that have been merged and modified. In this way, we can obtain the bugs to be tested and their corresponding file data.
[0068] In some embodiments, the file data may correspond to the code in the data to be tested.
[0069] In some embodiments, if a bug to be tested has multiple code entries merged into it, the bug to be tested is split into relationships corresponding to the multiple code entries and written into the corresponding data table to obtain the file data of the bug to be tested.
[0070] S202. Input the file data corresponding to the bug to be tested into the pre-trained first model to obtain the target functional module corresponding to the bug to be tested.
[0071] In some embodiments, the pre-trained first model is used to obtain the target functional module of the bug to be tested.
[0072] In some embodiments, the target functional module is the module executed by the bug to be tested, such as a payment module or a security module, and no specific restrictions are made here.
[0073] In some embodiments, the pre-trained first model can be a logistic regression model.
[0074] In some embodiments, the pre-trained first model can be a machine model or a neural network model, without specific limitations.
[0075] In some embodiments, the file data corresponding to the bug to be tested is input into a pre-trained first model to obtain the target functional module output by the pre-trained first model.
[0076] In some embodiments, the number of target functional modules can be one or more, such as the first model that outputs the one or more target functional modules with the highest probability in a pre-trained model, and can also output the predicted probability corresponding to each target functional module.
[0077] In some embodiments, the file data corresponding to each bug to be tested is input into a pre-trained second model to obtain the target functional module of each bug to be tested.
[0078] S203. Input the file data corresponding to the bug to be tested into the pre-trained second model to obtain the target test cases corresponding to the bug to be tested.
[0079] In some embodiments, the pre-trained second model is used to obtain target test cases for the bug to be tested.
[0080] In some embodiments, the pre-trained second model can be a random forest.
[0081] In some embodiments, the pre-trained second model can be a machine model or a neural network model, without specific limitations.
[0082] In some embodiments, the file data corresponding to the bug to be tested is input into a pre-trained second model to obtain the target test case output by the pre-trained second model.
[0083] In some embodiments, the number of target test cases can be one or more, such as the pre-trained second model outputting one or more target test cases with the highest probability, and can also output the predicted probability corresponding to each target test case.
[0084] In some embodiments, the file data corresponding to each bug to be tested is input into a pre-trained second model to obtain the target test cases for each bug to be tested.
[0085] S204. Test the bugs to be tested based on the target functional modules and target test cases.
[0086] In some embodiments, once the target functional module and target test cases are obtained, they can be uploaded to a visualization structure for display.
[0087] In some embodiments, the target functional module, target test cases, predicted probability of the target functional module, predicted probability of the target test cases, bug number of the bug to be tested, and text data can be uploaded to a visualization structure for display.
[0088] In some embodiments, the bug to be tested can be tested directly based on the target functional module and the target test case.
[0089] In some embodiments, there are multiple target functional modules and target test cases. One target functional module and one target test case can be selected for testing the bug by combining the predicted probabilities of the target functional modules and the target test cases. For example, weights can be set for the target functional modules and target test cases based on the predicted probabilities of the target functional modules and target test cases, and then the priorities of the target functional modules and target test cases can be calculated. By sorting the priorities and analyzing information such as the relevance of the target functional modules and the problem description, one target functional module and one target test case can be selected for testing the bug, thereby improving the accuracy of the recommendation.
[0090] In some embodiments, the execution order of steps S202 and S203 is optional, such as step S203 being executed before step S202.
[0091] In this embodiment of the application, during testing, the data to be tested is analyzed to determine one or more bugs to be tested, as well as the file data of the bugs to be tested. By inputting the file data into a pre-trained first model and a pre-trained second model respectively, the target functional module and target test cases of the bugs to be tested are obtained accordingly. In this way, the target functional module and target test cases can be obtained without human intervention. Subsequently, the bugs to be tested can be tested based on the target functional module and target test cases output by the pre-trained first model and the pre-trained second model, thereby improving the efficiency and reliability of testing.
[0092] Figure 3 Flowchart of the test method provided in this application Figure 2 ,like Figure 3 As shown, in this embodiment... Figure 2 Based on the embodiments, a training method for a pre-trained first model and a pre-trained second model is also proposed, which includes:
[0093] S301. Determine training data based on historical test data, the first historical code path data of historical test data, and test case result data.
[0094] In some embodiments, historical test data may include historical test code data.
[0095] In some embodiments, the first historical code path data is the source code coverage code path data obtained by executing the first historical test case corresponding to the historical test data.
[0096] In some embodiments, the test case result data is the result data obtained during historical testing processes.
[0097] In some embodiments, during testing, new or existing historical test bugs may be added, and the test case results data can be used to identify these historical test bugs.
[0098] In some embodiments, test case result data can be test case bug analysis data.
[0099] In some embodiments, historical test data, first historical code path data, and test case result data can be obtained through test data and code instrumentation. The test data includes issues discovered by the test cases, and the filename data of the modified code files for these issues; code instrumentation can obtain the code paths covered by the test case execution.
[0100] In some embodiments, the relationship between test cases and test code files is established through test data and data obtained by code instrumentation, and a database is built, maintained, and automatically updated periodically to obtain historical test data, first historical code path data, and test case result data.
[0101] In some embodiments, based on historical test data and first historical code path data, a first mapping data is determined between the first historical functional module corresponding to the historical test data and the first historical code path data, and a second mapping data is determined between the first historical test case corresponding to the historical test data and the first historical code path data.
[0102] In some embodiments, historical test bugs and corresponding second historical test cases, second historical functional modules, and second historical code path data are determined based on test case result data. Third mapping data between the second historical functional modules and the second historical code path data, and fourth mapping data between the second historical test cases and the second historical code path data are also determined.
[0103] In some embodiments, training data is determined based on first mapping data, third mapping data, first historical test cases, first historical functional modules, first historical code paths, second historical test cases, second historical functional modules, and second historical code paths.
[0104] Establish a mapping relationship between the first historical functional module and the first historical code path data to obtain the first mapping data, and establish a mapping relationship between the first historical test case and the first historical code path data to obtain the second mapping data.
[0105] In some embodiments, if multiple bugs exist in the historical test data, then a first mapping data and a second mapping data corresponding to each bug are established.
[0106] In some embodiments, historical test bugs are newly added bugs that have been merged into the code.
[0107] In some embodiments, historical test bugs are identified from test case result data and preprocessed. If a historical test bug has multiple code entries, it is split into multiple data entries, and the second historical test case, second historical functional module, and second historical code path data are written into the corresponding data table.
[0108] Establish a mapping relationship between the second historical functional modules and the second historical code path data to obtain the third mapping data, and establish a mapping relationship between the second historical test cases and the second historical code path data to obtain the fourth mapping data.
[0109] In some embodiments, the third mapping data is appended to the training data after undergoing data preprocessing methods such as deduplication, path merging, and standardization.
[0110] In some embodiments, the third mapping data is deduplicated based on the first mapping data to obtain the deduplicated third mapping data, and the deduplicated third mapping data, the first mapping data, the second mapping data, and the third mapping data are determined as training data.
[0111] In some embodiments, the fourth mapping relationship is not deduplicated from the second mapping relationship. That is, the correspondence between historical test cases and historical code path data is not deduplicated. In this way, the training data can reflect which test case in a code path has the most problems detected. When recommending test cases, the recommendation probability will be increased, thereby improving the reliability of the pre-trained second model.
[0112] In some embodiments, the training data includes first mapping data, second mapping data, third mapping data, and fourth mapping data.
[0113] In some embodiments, by learning from a large amount of training data, the accuracy and relevance of the pre-trained first model and the pre-trained second model are improved. The training data is then categorized, summarized, stored, and compiled according to different testing requirements, functions, and test item information, thereby accumulating training data.
[0114] In some embodiments, the training data may include multiple test items, one of which is used for training an initial first model or for iterative training of an initial second model.
[0115] In some embodiments, a test item includes first and second mapping data corresponding to a bug in historical test data, or a test item includes third and fourth mapping data corresponding to a historical test bug.
[0116] In this embodiment of the application, when determining training data, not only is historical test data obtained, but also relevant data of historical test bugs with new code merged are obtained based on the test case result data, thereby enriching the amount of training data and improving the reliability of subsequent model training.
[0117] S302. Train the initial first model based on the training data to obtain the pre-trained first model.
[0118] In some embodiments, the server where the initial first model training takes place may be the same as or different from the server where the pre-trained first model works. For example, the initial first model training may be performed on server A, and the pre-trained first model may be deployed to server B.
[0119] In some embodiments, the initial training process of the first model includes model selection, training, evaluation, optimization, and deployment.
[0120] In some embodiments, when training an initial first model based on training data, the training data may be preprocessed, such as performing one or more of the following: data cleaning, missing value handling, poem conversion, data integration, and normalization.
[0121] In some embodiments, the initial first model is a logistic regression model.
[0122] Logistic regression is a typical linear classifier, a machine learning method used to solve binary (0 or 1) classification problems. It estimates the probability of something by using a weighted sum of linear functions to non-linearly transform input features into a probability value between 0 and 1, representing the probability of belonging to a certain class. For multi-class classification problems, it can be decomposed into multiple binary classification problems. For each class, a binary classification model is created, treating that class as the "positive class" and the other classes as the "negative class." For a problem with N classes, N binary classification models are generated. When a new sample needs to be classified, each binary classification model provides a predicted score, and the class with the highest predicted score is selected as the final classification result.
[0123] During testing, a functional module corresponds to multiple code paths, and the number of functional module categories is relatively small. The initial first model uses a weighted logistic regression model, which has a fast training and testing speed and can dynamically adjust the classification threshold.
[0124] In some embodiments, historical functional module labels of the training data are determined; an initial first model is trained based on the training data and the historical functional module labels to obtain a pre-trained first model.
[0125] In some embodiments, for the first mapping data and the second mapping data corresponding to a bug in the historical test data, the corresponding historical functional module label can be the first historical functional module, and the corresponding historical test case label can be the first historical test case.
[0126] In some embodiments, the historical functional module labels of a test item can also be manually labeled.
[0127] In some embodiments, such as Figure 4 As shown, during the training of the initial first model, the weighted data and loss function of the initial first model are first initialized, and then the training data and historical function module labels are loaded. During model training, the gradient descent linear fitting module is called to initialize the weights. It is then determined whether the number of iterations for training the initial first model has been reached. If it has, the evaluation of the trained initial first model is performed to obtain the classification accuracy. Then, it is determined whether the classification accuracy is optimal. If the classification accuracy is not optimal, the relevant parameters, weighted data, and weighted threshold are adjusted, and the process returns to the step of initializing the weighted data and loss function. If the classification accuracy is optimal, the trained initial first model is determined as the pre-trained first model.
[0128] The initial training iteration count of the first model has not been reached. Initialize m row vectors to record the vector positions of the iterations and determine whether the iteration of all rows of data has been completed.
[0129] In some embodiments, after all rows of data have been looped through, the process proceeds to determine whether the number of loop iterations has been reached. If all rows of data have not been looped through, the alpha value (regularization parameter) is calculated, a row of training data is randomly selected, the inner product of the data in this row is calculated according to the weights, and the probability value is calculated. The loss value is calculated according to the historical functional module labels and the probability value generated last time, and the weight value is recalculated. Then, the process proceeds to determine whether all rows of data have been looped through.
[0130] In some embodiments, the initial first model dynamically adjusts the classification threshold and performs weighted processing on data with obvious functional module features. This data with obvious functional module features comes partly from manual annotation and partly from the processing of the mapping relationship between functional modules and code path data (such as the first mapping data and the third mapping data). The keywords with high occurrence probability are obtained by summarizing. The model optimization uses the stochastic gradient descent method, which is fast and can suppress the occurrence of local optima to a certain extent.
[0131] In some embodiments, a loss function (such as log-likelihood loss) is added at the end of the initial training of the first model. This allows the loss value to be calculated based on the difference between probability distributions. The loss function is used to measure the difference between the model's predicted probability distribution and the actual label distribution. This reflects the model's accuracy and performance, helps to find the optimal model parameters, and makes the model's prediction results closer to the actual observation results. By comparing the evaluation data before and after the adjustment, the prediction accuracy is improved from more than 45% to about 97%.
[0132] S303. Train the initial second model based on the training data to obtain the pre-trained second model.
[0133] In some embodiments, the server on which the initial second model training takes place may be the same as or different from the server on which the pre-trained second model works. For example, the initial second model training may be performed on server A, and the pre-trained second model may be deployed to server B.
[0134] In some embodiments, the initial second model is a random forest.
[0135] Random forest is a machine learning algorithm based on decision trees. It utilizes the power of multiple decision trees to make decisions. Each node in a decision tree is a random subset of features used to calculate the output. Random forest integrates the outputs of individual decision trees to generate the final output result. In classification problems, random forest can determine the category of the test data by taking the mode.
[0136] In some embodiments, one test case corresponds to multiple code paths, and one code path corresponds to one or more test cases. There are many types of test cases. The initial second model using the logistic regression model to generate a multi-classification model is prone to overfitting. Moreover, the correspondence between test cases and paths is complex. Therefore, the initial second model uses random forest.
[0137] In some embodiments, historical test case labels of the training data are determined; the initial second model is trained based on the training data and the historical test case labels to obtain a pre-trained second model.
[0138] In some embodiments, for third and fourth mapping data corresponding to a historical test bug in historical test data, the corresponding historical functional module label can be a second historical functional module, and the corresponding historical test case label can be a second historical test case.
[0139] In some embodiments, the historical test case labels for a test item can also be manually labeled.
[0140] In some embodiments, such as Figure 5 As shown, taking random forest as an example, during the training of the initial second model, the input training data is used to initialize the default parameters of the initial second model. The training data is randomly sampled with replacement to generate multiple subsets. Each subset makes a decision through a decision tree, such as "tree-1", "tree-2", and "tree-k". The outputs of the decision trees of all subsets vote to determine the optimal classification, and the initial second model is evaluated to determine whether the number of decision trees and the number of node branch variables are optimal. If the result is yes, the initial second model is output, that is, the pre-trained second model; if the result is no, the process enters the step of adjusting relevant parameters and then returns to the step of initializing the default parameters of the initial second model.
[0141] In some embodiments, the initial second model employs a random forest algorithm, which effectively handles large amounts of input data. During training, it can automatically perform feature selection and dimensionality reduction to help find the most important features. This training process only requires adjusting hyperparameters such as the number of decision trees, the maximum depth of the trees, and the number of samples in the leaf nodes. For example, first, each parameter is coarsely tuned to obtain the optimization effect and model evaluation results; then, regions with good performance are selected from the coarsely tuned data for fine-tuning within these regions; finally, the optimal solutions for each hyperparameter are integrated into the model for concentrated fine-tuning. Comparing the evaluation data before and after adjustment, the probability of the pre-trained second model outputting correct test cases increases from 95% before optimization to approximately 98%.
[0142] In some embodiments, the execution order of steps S302 and S303 is optional, such as step S303 being executed before step S302.
[0143] This application proposes to predict test cases and functional modules using two different models. This process does not require GPU resources and can quickly and accurately recommend functional modules and test cases.
[0144] Figure 6 A schematic diagram of the test apparatus provided in this application is shown below. Figure 6 As shown, the testing apparatus 60 provided in this embodiment includes:
[0145] File data determination module 610 is used to determine the file data corresponding to at least one defect bug to be tested based on the test data;
[0146] The first prediction module 620 is used to input the file data corresponding to the bug to be tested into the pre-trained first model to obtain the target functional module corresponding to the bug to be tested.
[0147] The second prediction module 630 is used to input the file data corresponding to the bug to be tested into the pre-trained second model to obtain the target test cases corresponding to the bug to be tested.
[0148] Test module 640 is used to test the bugs to be tested based on the target functional module and the target test cases.
[0149] In some embodiments, the testing apparatus 60 further includes:
[0150] The training data acquisition module is used to determine training data based on historical test data, the first historical code path data of historical test data, and test case result data.
[0151] The first training module is used to train the initial first model based on the training data to obtain the pre-trained first model;
[0152] The second training module is used to train the initial second model based on the training data to obtain the pre-trained second model.
[0153] In some embodiments, the training data acquisition module includes:
[0154] The first mapping unit is used to determine, based on historical test data and first historical code path data, the first mapping data between the first historical functional module corresponding to the historical test data and the first historical code path data, and the second mapping data between the first historical test case corresponding to the historical test data and the first historical code path data.
[0155] The second mapping unit is used to determine historical test bugs and the corresponding second historical test cases, second historical functional modules, and second historical code path data based on test case result data, and to determine the third mapping data between the second historical functional modules and the second historical code path data, as well as the fourth mapping data between the second historical test cases and the second historical code path data.
[0156] The training data acquisition unit is used to determine training data based on the first mapping data, the third mapping data, the first historical test cases, the first historical functional modules, the first historical code paths, the second historical test cases, the second historical functional modules, and the second historical code paths.
[0157] In some embodiments, the training data acquisition unit includes:
[0158] The deduplication module is used to deduplicatize the third mapping data based on the first mapping data, so as to obtain the deduplicated third mapping data.
[0159] The training data acquisition section is used to determine the deduplicated third mapping data, as well as the first, second, and third mapping data, as training data.
[0160] In some embodiments, the first training module includes:
[0161] The first annotation unit is used to determine the historical functional module labels of the training data;
[0162] The first training unit is used to train the initial first model based on training data and historical functional module labels to obtain the pre-trained first model.
[0163] In some embodiments, training an initial second model based on training data to obtain a pre-trained second model includes:
[0164] The second annotation unit is used to determine the historical test case labels of the training data;
[0165] The second training unit is used to train the initial second model based on training data and historical test case labels to obtain a pre-trained second model.
[0166] The testing device provided in this embodiment can execute the testing method provided in the above method embodiment. Its implementation principle and technical effect are similar, and will not be described in detail here.
[0167] Figure 7 A schematic diagram of the structure of the electronic device provided in this application. Figure 7 As shown, the electronic device 70 provided in this embodiment includes at least one processor 701 and a memory 702. Optionally, the device 70 further includes a communication component. The processor 701, memory 702, and communication component are connected via a bus 703.
[0168] In a specific implementation, at least one processor 701 executes computer execution instructions stored in memory 702, causing at least one processor 701 to perform the above-described method.
[0169] The specific implementation process of processor 701 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0170] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0171] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0172] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0173] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0174] This application also provides a chip including at least one processor. The processor is used to call a computer program in memory to execute the technical solutions in the above embodiments. Its implementation principle and technical effects are similar to the related embodiments described above, and will not be repeated here.
[0175] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0176] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0177] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0178] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, 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 indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0179] 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.
[0180] In addition, the functional units in the various embodiments of the present invention 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.
[0181] If a function 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, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0182] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0183] The above testing method can be performed using a chip or a chip module; the testing device can be, for example, a chip or a chip module.
[0184] Regarding the modules / units included in the various devices and products described in the above embodiments, they can be software modules / units, hardware modules / units, or a combination of both. For example, for various devices and products applied to or integrated into a chip, all of their modules / units can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs running on a processor integrated within the chip, while the remaining modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into a chip module, all of their modules / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules... Each module / unit can be implemented using software programs that run on a processor integrated within the chip module. The remaining modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into the terminal, each module / unit can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components within the terminal. Alternatively, at least some modules / units can be implemented using software programs that run on a processor integrated within the terminal, while the remaining modules / units can be implemented using hardware methods such as circuits.
[0185] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A testing method, characterized in that, include: Based on the test data, determine the file data corresponding to at least one defect / bug to be tested; The file data corresponding to the bug to be tested is input into the pre-trained first model to obtain the target functional module corresponding to the bug to be tested; The file data corresponding to the bug to be tested is input into the pre-trained second model to obtain the target test cases corresponding to the bug to be tested; The bug to be tested is performed based on the target functional module and the target test case.
2. The method according to claim 1, characterized in that, The method further includes: Training data is determined based on historical test data, the first historical code path data of the historical test data, and test case result data. The initial first model is trained based on the training data to obtain the pre-trained first model; The initial second model is trained based on the training data to obtain the pre-trained second model.
3. The method according to claim 2, characterized in that, The training data determined based on historical test data, the first historical code path data of the historical test data, and test case result data includes: Based on the historical test data and the first historical code path data, a first mapping data is determined between the first historical functional module corresponding to the historical test data and the first historical code path data, and a second mapping data is determined between the first historical test case corresponding to the historical test data and the first historical code path data. Based on the test case result data, determine the historical test bugs and the corresponding second historical test cases, second historical functional modules, and second historical code path data. Determine the third mapping data between the second historical functional modules and the second historical code path data, as well as the fourth mapping data between the second historical test cases and the second historical code path data. The training data is determined based on the first mapping data, the third mapping data, the first historical test cases, the first historical functional modules, the first historical code paths, the second historical test cases, the second historical functional modules, and the second historical code paths.
4. The method according to claim 3, characterized in that, The step of determining the training data based on the first mapping data, the third mapping data, the first historical test cases, the first historical functional modules, the first historical code paths, the second historical test cases, the second historical functional modules, and the second historical code paths includes: Based on the first mapping data, the third mapping data is deduplicated to obtain the deduplicated third mapping data. The deduplicated third mapping data, along with the first mapping data, the second mapping data, and the third mapping data, are determined as the training data.
5. The method according to claim 2, characterized in that, The step of training the initial first model based on the training data to obtain the pre-trained first model includes: Determine the historical functional module labels of the training data; The initial first model is trained based on the training data and the historical functional module labels to obtain the pre-trained first model.
6. The method according to claim 2, characterized in that, The step of training the initial second model based on the training data to obtain the pre-trained second model includes: Determine the historical test case labels of the training data; The initial second model is trained based on the training data and the historical test case labels to obtain the pre-trained second model.
7. A testing apparatus, characterized in that, include: The file data determination module is used to determine the file data corresponding to at least one defect or bug to be tested based on the test data. The first prediction module is used to input the file data corresponding to the bug to be tested into the pre-trained first model to obtain the target functional module corresponding to the bug to be tested. The second prediction module is used to input the file data corresponding to the bug to be tested into the pre-trained second model to obtain the target test cases corresponding to the bug to be tested; The testing module is used to test the bug to be tested based on the target functional module and the target test cases.
8. An electronic device, characterized in that, include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory to implement the method as described in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-6.
10. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method as described in any one of claims 1-6.