Test case optimization method and system based on artificial intelligence
Through the test case optimization method based on artificial intelligence, and the machine learning model is used to optimize test cases, the problem of inadequate test case design in the existing technology is solved, and a more efficient test process and quality is achieved.
Patent Information
- Application Number
- CN202411145413.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-20
- Publication Date
- 2024-12-27
AI Technical Summary
The design of existing test cases is not intelligent enough, requires a lot of manual intervention, lacks scientific optimization methods and tools, cannot respond quickly to changes and continuously improve the testing process, and it is difficult to deal with complex software systems and application scenarios.
Using an artificial intelligence-based test case optimization method, we collect and preprocess the execution result data of test cases, perform feature engineering, train machine learning models, and optimize test cases to improve coverage and execution efficiency.
Improve the coverage and execution efficiency of test cases, reduce manual intervention, reduce test costs, be able to respond quickly to changes, continuously improve the testing process, and improve test quality and efficiency.
Smart Images

Figure CN119201679A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a test case optimization method and system based on artificial intelligence. Background Art
[0002] In software development, a test case is a detailed set of steps and conditions used to verify whether the software application meets the requirements specifications in terms of functionality, performance, stability, etc. Test cases are an important part of the testing process, which ensures that the software system works as expected under various conditions. A test case usually includes the following main parts: test case identification, test title, preconditions, test steps, test results, postconditions, and test priority.
[0003] The design of existing test cases is not intelligent enough, and a lot of manual intervention and adjustment are required during the testing process, which makes the entire software testing process time-consuming and laborious. In addition, the execution result data of test cases lacks effective collection, processing, and analysis processes, resulting in poor test results. Due to the lack of scientific methods and tools for test case optimization, it is impossible to quickly respond to changes and continuously improve the testing process. Existing testing methods and technologies are difficult to cope with complex software systems and application scenarios, resulting in unsatisfactory test results. Summary of the invention
[0004] The main purpose of the present invention is to provide a test case optimization method and system based on artificial intelligence, aiming to solve the problem that the optimization of test cases in the prior art lacks scientific analysis methods and tools, resulting in the inability to quickly respond to changes and continuously improve the test process.
[0005] To achieve the above object, the present invention provides a test case optimization method based on artificial intelligence, and the test case optimization method based on artificial intelligence comprises the following steps: Collecting test case execution result data and preprocessing the collected test case execution result data; Perform feature engineering on the execution result data of the preprocessed test cases to extract the execution features of the test cases; The selected machine learning model is trained according to the execution characteristics of the extracted test cases and the set test objectives to obtain a test case optimization model; The execution result of the input test case is predicted based on the test case optimization model, the predicted execution result is analyzed, and the input test case is optimized according to the analysis result to obtain an optimized test case.
[0006] Optionally, the collecting of the test case execution result data and preprocessing the collected test case execution result data specifically includes: Collect and store the execution results, execution time and exception information of the test cases during the test process, and obtain the execution result data of the test cases after statistical analysis; The execution result data of the test case is cleaned, deduplicated and formatted to obtain the execution result data of the preprocessed test case.
[0007] Optionally, the collecting and storing the execution results, execution time and exception information of the test cases during the test process, and obtaining the execution result data of the test cases after statistical analysis, specifically includes: Defining the test case, determining the test steps, expected results and test data of the test case; The test case is tested based on a test management tool, and the test case identification, execution result, execution time and abnormal information during the test process are collected and stored, and the execution result data of the test case is obtained after statistical analysis.
[0008] Optionally, the performing feature engineering processing on the execution result data of the preprocessed test case to extract the execution features of the test case specifically includes: Extracting the path length and branch conditions of the test case during execution, identifying and recording repeated steps, and obtaining the execution path characteristics of the test case; Record the pass status, error type, and execution result characteristics of the test case, and count the number of failures and failed steps to obtain the execution result characteristics of the test case; The total execution time, average execution time, maximum execution time and minimum execution time of the test case are calculated, and the timed-out test case is detected to obtain the execution time characteristics of the test case.
[0009] Optionally, the step of training the selected machine learning model according to the extracted execution characteristics of the test case and the set test objectives to obtain the test case optimization model specifically includes: Determine the test target, and select a corresponding machine learning model according to the test target and the execution characteristics of the extracted test case; Performing data segmentation on the execution result data of the preprocessed test cases to obtain a training set, a validation set, and a test set; Training the selected machine learning model based on preset hyperparameters and the training set, evaluating model performance using the validation set, and adjusting hyperparameters to optimize performance; An evaluation indicator is selected according to the test objective, and the test case optimization model is obtained after optimization based on the evaluation result.
[0010] Optionally, the predicting the execution result of the input test case based on the test case optimization model and analyzing the predicted execution result specifically includes: Based on the test case optimization model, predicting the execution result of the test case to obtain the predicted execution result of the test case; According to the prediction execution results, key factors affecting the prediction results of the test cases are identified, the accuracy and reliability of the prediction results are checked, and the test cases are classified and sorted according to the prediction results.
[0011] Optionally, optimizing the input test case according to the analysis result to obtain an optimized test case specifically includes: According to the key factors, the classification and sorting of the test cases, redundant test cases are deleted, the test coverage is adjusted, and the execution order of the test cases is optimized to obtain the optimized test cases.
[0012] In addition, to achieve the above-mentioned purpose, the present invention also provides a test case optimization system based on artificial intelligence, wherein the test case optimization system based on artificial intelligence includes: A data processing module, used to collect the execution result data of the test cases and pre-process the collected execution result data of the test cases; The feature extraction module is used to perform feature engineering processing on the execution result data of the preprocessed test cases to extract the execution features of the test cases; A model training module is used to train the selected machine learning model according to the execution characteristics of the extracted test cases and the set test objectives to obtain a test case optimization model; The test case optimization module is used to predict the execution result of the input test case based on the test case optimization model, analyze the predicted execution result, and optimize the input test case according to the analysis result to obtain an optimized test case.
[0013] In addition, to achieve the above-mentioned purpose, the present invention also provides a terminal, wherein the terminal includes: a memory, a processor, and an artificial intelligence-based test case optimization program stored in the memory and executable on the processor, and when the artificial intelligence-based test case optimization program is executed by the processor, the steps of the artificial intelligence-based test case optimization method as described above are implemented.
[0014] In addition, to achieve the above-mentioned purpose, the present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores an artificial intelligence-based test case optimization program, and when the artificial intelligence-based test case optimization program is executed by a processor, the steps of the artificial intelligence-based test case optimization method as described above are implemented.
[0015] In the present invention, the test cases are optimized by artificial intelligence algorithms, which can improve the coverage and execution efficiency of the test cases, thereby improving the test effect; at the same time, the execution results of the test cases can be automatically analyzed, and the test cases can be automatically optimized, reducing manual intervention and reducing testing costs; and, the changes in test requirements can be quickly responded to, the test cases can be optimized in time, and the test response speed can be improved; and the test process can be continuously improved, the test cases can be continuously optimized, and the quality and efficiency of the test can be improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] Figure 1 It is a flow chart of a preferred embodiment of the test case optimization method based on artificial intelligence of the present invention; Figure 2 It is a structural diagram of a preferred embodiment of the test case optimization system based on artificial intelligence of the present invention; Figure 3 It is a structural diagram of a preferred embodiment of the terminal of the present invention. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solution and advantages of the present invention clearer and more specific, the present invention is further described in detail below with reference to the accompanying drawings and examples. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0018] The design of existing test cases is not intelligent enough, and a lot of manual intervention and adjustment are required during the testing process, which makes the entire software testing process time-consuming and laborious. In addition, the execution result data of test cases lacks effective collection, processing, and analysis processes, resulting in poor test results. Due to the lack of scientific methods and tools for test case optimization, it is impossible to quickly respond to changes and continuously improve the testing process. Existing testing methods and technologies are difficult to cope with complex software systems and application scenarios, resulting in unsatisfactory test results.
[0019] In order to solve the problem that the optimization of test cases in the prior art lacks scientific analysis methods and tools, resulting in the inability to quickly respond to changes and continuously improve the test process, an artificial intelligence-based test case optimization method is provided in an embodiment of the present invention, which collects the execution result data of the test cases and preprocesses the collected execution result data of the test cases; performs feature engineering processing on the execution result data of the preprocessed test cases to extract the execution features of the test cases; trains the selected machine learning model according to the extracted execution features of the test cases and the set test goals to obtain a test case optimization model; predicts the execution results of the input test cases based on the test case optimization model, analyzes the predicted execution results, and optimizes the input test cases according to the analysis results to obtain optimized test cases. The present invention optimizes test cases using artificial intelligence algorithms, which can improve the coverage and execution efficiency of test cases, thereby improving the effect of testing.
[0020] The test case optimization method based on artificial intelligence described in the preferred embodiment of the present invention is as follows: Figure 1 As shown, the test case optimization method based on artificial intelligence includes the following steps: Step S10: Collect the execution result data of the test cases, and pre-process the collected execution result data of the test cases.
[0021] It should be noted that in the present application, the test case optimization method based on artificial intelligence mainly utilizes artificial intelligence algorithms (machine learning models) to optimize test cases, which can improve the coverage and execution efficiency of test cases, thereby improving the test effect; at the same time, it can automatically analyze the execution results of test cases, and automatically optimize test cases, reduce manual intervention, and reduce testing costs; and it can quickly respond to changes in test requirements, optimize test cases in a timely manner, and improve the response speed of the test; and it can continuously improve the testing process, continuously optimize test cases, and improve the quality and efficiency of the test.
[0022] It is understood that in this application, a test case refers to a test sample of detailed steps and conditions used to verify whether the software application meets the requirements specification in terms of functionality, performance, stability, etc. Test cases are an important part of the testing process, which ensures that the software system works as expected under various conditions.
[0023] For ease of understanding, the test cases described in this application may be test cases of multiple different test functions, for example, test case A, test case B, test case C, test case D, etc. for testing different software; generally, a test case includes the following main parts: 1) Test case identification: Each test case usually has a unique number or identifier for easy tracking and management.
[0024] 2) Test Title: The name or title of the test case, which concisely and clearly describes the goal or function of the test.
[0025] 3) Preconditions: Conditions or settings that must be met before the test can begin. For example, some tests may require specific user login status, data initialization, or system configuration.
[0026] 4) Test steps: The specific operation steps in the test case are listed in order, describing how to perform the test. Each step should be clear and easy to follow.
[0027] 5) Input data: data or parameters that need to be used during the test. These data should cover a variety of possible scenarios, including normal data and boundary data.
[0028] 6) Expected results: Based on the test steps and input data, the expected system behavior or results should be shown. This part is used to compare the actual results with the expected results to determine whether the test passes.
[0029] 7) Actual results: The performance of the system after the actual test. The actual observations recorded by the tester are used to compare with the expected results.
[0030] 8) Postconditions: The state or cleanup steps after the test is executed. If the test modifies the system or generates data, it is necessary to describe how to restore the system to its original state.
[0031] 9) Test priority: Indicates the priority of the test case to help decide which test cases should be executed first. Usually divided into high, medium and low priority.
[0032] In the present application, the execution result data of these different test cases in the corresponding test process are collected, and the collected execution result data of the test cases are preprocessed so as to extract corresponding data features from the execution result data of these different test cases, and these extracted data features are used as training samples to train a test case optimization model; finally, the trained model is used to optimize these test cases, thereby improving the coverage and execution efficiency of the test cases.
[0033] Furthermore, the execution result data of the test cases are collected and the collected execution result data of the test cases are preprocessed, specifically including: collecting and storing the execution results, execution time and exception information of the test cases during the test process, and obtaining the execution result data of the test cases after statistical analysis; and cleaning, deduplicating and formatting the execution result data of the test cases to obtain the preprocessed execution result data of the test cases.
[0034] Specifically, in this application, collecting the execution result data of the test cases is an important step in the software testing process, which can help evaluate the quality of the software and determine whether it meets the expected requirements. Effective data collection not only helps to identify defects in the software, but also provides a basis for subsequent improvements; in this application, the execution results, execution time and abnormal information of the test cases in the test process are collected and stored, and the execution result data of the test cases are obtained after statistical analysis; then, the collected execution result data are processed by data preprocessing methods such as data cleaning, data standardization, data conversion, data integration and data verification, so as to obtain preprocessed data for feature engineering processing.
[0035] Furthermore, the collection and storage of execution results, execution time and exception information of test cases in the testing process, and obtaining the execution result data of the test cases after statistical analysis, specifically includes: defining the test cases, determining the test steps, expected results and test data of the test cases; testing the test cases based on a test management tool, collecting and storing the test case identification, execution results, execution time and exception information in the testing process, and obtaining the execution result data of the test cases after statistical analysis.
[0036] Specifically, in this application, the test case is first defined to determine the test steps, expected results, and test data of the test case; then, when executing the test case, the operation and results of each step are recorded through a test management tool (such as Jira, TestRail, Azure DevOps). This usually includes: execution time, test environment (such as operating system version, browser type, etc.), input data, actual results, etc. In addition to recording the operation and results of each step, screenshots and logs can also be captured, that is, when the test fails, screenshots, error messages, and log files are captured, which helps to analyze the root cause of the problem.
[0037] When executing test cases, the recorded execution status of the test cases includes: pass, fail, block, skip; the recorded execution results of each test case include: test case number and title, actual result, problem description (if there is a failure), executor (tester), and execution time, etc. After that, compare and analyze the differences between the actual results and the expected results, identify functional defects or problems, organize and summarize the test results, and generate a test report. The report usually includes: test case execution summary (number of passes, failures, blocks, and skips) detailed description of failed cases defects or problems found and their severity improvement suggestions or repair measures. After the above statistical analysis, the execution result data of the test case is obtained.
[0038] Specifically, in the present application, preprocessing the collected test case execution result data is a key step to ensure data quality and analysis accuracy. Preprocessing includes data cleaning, sorting, conversion and integration, with the aim of improving data consistency, integrity and availability. Among them, data cleaning includes: steps of removing duplicate data, correcting erroneous data and processing missing values; data sorting refers to unified processing according to a unified data format; data conversion and integration refers to converting data from its original format to the format required for analysis, such as converting log files into structured tabular data, and then integrating data sources from different test environments or tools into a unified data set; after the above data preprocessing process, the execution result data of the preprocessed test case can be obtained.
[0039] Step S20: Perform feature engineering processing on the execution result data of the preprocessed test case to extract the execution features of the test case.
[0040] Specifically, in the present application, feature engineering processing is performed on the execution result data of the preprocessed test cases to extract the execution path features, execution result features, and execution time features of the test cases, which can help analyze the performance, reliability, and potential problems of the test cases, thereby enabling a more comprehensive training model.
[0041] Furthermore, the execution result data of the preprocessed test case is subjected to feature engineering processing to extract the execution characteristics of the test case, specifically including: extracting the path length and branch conditions of the test case during the execution process, identifying and recording repeated steps, and obtaining the execution path characteristics of the test case; recording the pass status, error type and execution result characteristics of the test case, and counting the number of failures and failed steps to obtain the execution result characteristics of the test case; calculating the total execution time, average execution time, maximum execution time and minimum execution time of the test case, and detecting timed-out test cases to obtain the execution time characteristics of the test case.
[0042] Specifically, in this application, feature engineering processing mainly involves extracting the execution path features, execution result features, and execution time features of the test case. The following are specific methods for extracting the three features: 1) Path feature extraction: Extract path length (i.e., the number of steps passed during the test case execution), branch conditions (the execution status of each branch condition: whether it is satisfied, which branch is selected), etc. Identify and record repeated steps (i.e., identify and count whether there are repeated steps in the execution process).
[0043] 2) Result feature extraction: record the pass status of each test case (i.e. the marked pass / fail status of the test case), error type (i.e. the error type or exception information when the execution fails, such as system error, logic error, timeout, etc.). Count the number of failures (i.e. the total number of failures of each test case at different executions) and the failed steps (i.e. the specific steps or conditions that caused the test case to fail).
[0044] 3) Time feature extraction: Calculate the total execution time, average execution time (i.e. the average execution time of a test case under multiple executions), maximum / minimum execution time. Detect timed-out test cases.
[0045] Through the above methods, the execution result data of the original test case can be converted into structured feature data. These features can then be used for machine learning model training, visual analysis, performance monitoring, etc., to improve the efficiency and effectiveness of the testing process.
[0046] Step S30: train the selected machine learning model according to the extracted execution characteristics of the test case and the set test objectives to obtain a test case optimization model.
[0047] Specifically, in the present application, for the execution features of the test cases extracted in the above step S20, by selecting an appropriate machine learning model and training it, different model testing objectives can be achieved based on execution path features, execution result features, and execution time features.
[0048] Furthermore, the selected machine learning model is trained according to the extracted execution characteristics of the test case and the set test objectives to obtain a test case optimization model, which specifically includes: determining the test objective, and selecting a corresponding machine learning model according to the test objective and the extracted execution characteristics of the test case; performing data segmentation on the execution result data of the preprocessed test case to obtain a training set, a validation set and a test set; training the selected machine learning model based on preset hyperparameters and the training set, and using the validation set to evaluate the model performance, and adjusting the hyperparameters to optimize the performance; selecting an evaluation indicator according to the test objective, and obtaining the test case optimization model after optimization based on the evaluation result.
[0049] Specifically, in this application, the following processing is first performed on the execution path features, execution result features, and execution time features of the extracted test cases: 1) Execute path features: Convert path features into numerical format, for example, using One-Hot encoding or Embedding.
[0050] 2) Execution result features: Use binary labels (pass / fail) or multi-category labels (different types of failure).
[0051] 3) Execution time characteristics: Calculate statistical characteristics, such as total time, average time, maximum time, etc.
[0052] Then, a machine learning model is selected, such as a decision tree, support vector machine, neural network, etc., and the execution result data of the preprocessed test case is segmented to divide the data set into a training set, a validation set, and a test set. Finally, the features are standardized (such as a mean of 0 and a standard deviation of 1) or normalized (such as scaling the data to a range of 0-1).
[0053] The training process of the machine learning model is as follows: 1) Set hyperparameters: Select appropriate hyperparameters and tune them (such as learning rate, number of trees, etc.).
[0054] 2) Training model: Use the training set to train the model.
[0055] 3) Validate model: Use the validation set to evaluate model performance and adjust hyperparameters to optimize performance.
[0056] After the model is trained, select evaluation indicators according to the test objectives, such as the accuracy of classification tasks, the mean square error (MSE) of regression tasks, the F1 score of anomaly detection, etc.; use the evaluation indicators to evaluate the machine learning model, and use methods such as cross-validation to optimize the performance of the model; finally, use the optimized model as the test case optimization model in this application.
[0057] Step S40: predicting the execution result of the input test case based on the test case optimization model, analyzing the predicted execution result, and optimizing the input test case according to the analysis result to obtain an optimized test case.
[0058] It should be noted that in the present application, in software testing, the goal of optimizing test cases is to improve test efficiency and accuracy, reduce redundancy, and ensure coverage of key functions; therefore, the present application analyzes the predicted execution results of the test cases through the trained test case optimization model, and then uses the analysis results to optimize the input test cases, so as to automatically obtain optimized test cases, reduce manual intervention, and reduce testing costs.
[0059] Furthermore, the execution result of the test case inputted is predicted based on the test case optimization model, and the predicted execution result is analyzed, specifically including: predicting the execution result of the test case based on the test case optimization model to obtain the predicted execution result of the test case; identifying the key factors affecting the predicted result of the test case according to the predicted execution result, checking the accuracy and reliability of the predicted result, and classifying and sorting the test cases according to the predicted result.
[0060] Specifically, in this application, the process of analyzing the test case prediction execution results includes the following steps: First, the test cases in the test set are input into the test case optimization model, and the execution results of these input test cases are predicted to obtain the predicted execution results of the test cases; then, the key factors are identified, that is, which factors (such as code changes, module dependencies) affect the predicted results of the test cases. And the prediction accuracy is evaluated, that is, the accuracy and reliability of the prediction results are checked, and possible errors or deviations are identified. Finally, classification and priority sorting are performed, that is, test cases are classified according to different prediction results, and priorities are set for test cases with high importance. Through the above analysis results, the input test cases can be optimized.
[0061] Furthermore, the input test cases are optimized according to the analysis results to obtain optimized test cases, specifically including: deleting redundant test cases, adjusting test coverage, and optimizing the execution order of the test cases according to the key factors, classification and sorting of the test cases to obtain the optimized test cases.
[0062] Specifically, in this application, the process of optimizing based on the test case prediction analysis results includes the following steps: First, remove redundant test cases. If the prediction results show that some test cases are redundant and no longer necessary, they can be removed from the test suite. Then, adjust the test coverage. That is, adjust the test cases to improve the coverage of key functions or modules based on the prediction results. It may be necessary to add new test cases or modify existing ones. And optimize the execution order of test cases. That is, reorder the execution order according to the importance and dependencies of the test cases to find problems faster. Finally, streamline the test cases. For areas where the prediction results are uncertain or the risks are high, streamline the test cases to reduce execution time and resource consumption.
[0063] Based on the analysis results, actual test cases are modified and updated. If possible, test cases are automated to improve execution efficiency and consistency. In the actual application process, the optimized test cases can also be executed to verify whether their effects meet expectations. Then, the strategy is adjusted to further adjust and optimize the test cases and their prediction models based on new test results and feedback.
[0064] In the present invention, the test cases are optimized by artificial intelligence algorithms, which can improve the coverage and execution efficiency of the test cases, thereby improving the test effect; at the same time, the execution results of the test cases can be automatically analyzed, and the test cases can be automatically optimized, reducing manual intervention and reducing testing costs; and, the changes in test requirements can be quickly responded to, the test cases can be optimized in time, and the test response speed can be improved; and the test process can be continuously improved, the test cases can be continuously optimized, and the quality and efficiency of the test can be improved.
[0065] Furthermore, if Figure 2 As shown, based on the above-mentioned test case optimization method based on artificial intelligence, the present invention also provides a test case optimization system based on artificial intelligence, wherein the test case optimization system based on artificial intelligence includes: The data processing module 21 is used to collect the execution result data of the test cases and pre-process the collected execution result data of the test cases; A feature extraction module 22 is used to perform feature engineering processing on the execution result data of the preprocessed test case to extract the execution features of the test case; A model training module 23 is used to train the selected machine learning model according to the extracted execution characteristics of the test case and the set test objectives to obtain a test case optimization model; The test case optimization module 24 is used to predict the execution result of the input test case based on the test case optimization model, analyze the predicted execution result, and optimize the input test case according to the analysis result to obtain an optimized test case.
[0066] Furthermore, if Figure 3As shown, based on the above-mentioned artificial intelligence-based test case optimization method and system, the present invention also provides a terminal accordingly, and the terminal includes a processor 10, a memory 20 and a display 30. Figure 3 Only some components of the terminal are shown, but it should be understood that it is not required to implement all of the components shown, and more or fewer components may be implemented instead.
[0067] In some embodiments, the memory 20 may be an internal storage unit of the terminal, such as a hard disk or memory of the terminal. In other embodiments, the memory 20 may also be an external storage device of the terminal, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (SecureDigital, SD) card, a flash card (Flash Card), etc. equipped on the terminal. Further, the memory 20 may also include both an internal storage unit of the terminal and an external storage device. The memory 20 is used to store application software and various types of data installed on the terminal, such as the program code of the installation terminal. The memory 20 may also be used to temporarily store data that has been output or is to be output. In one embodiment, a test case optimization program 40 based on artificial intelligence is stored on the memory 20, and the test case optimization program 40 based on artificial intelligence can be executed by the processor 10, thereby realizing the test case optimization method based on artificial intelligence in the present application.
[0068] In some embodiments, the processor 10 may be a central processing unit (CPU), a microprocessor or other data processing chip, used to run the program code or process data stored in the memory 20, such as executing the artificial intelligence-based test case optimization method.
[0069] In some embodiments, the display 30 may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, etc. The display 30 is used to display information on the terminal and to display a visual user interface. The components 10-30 of the terminal communicate with each other via a system bus.
[0070] In one embodiment, when the processor 10 executes the artificial intelligence-based test case optimization program 40 in the memory 20, the following steps are implemented: Collecting test case execution result data and preprocessing the collected test case execution result data; Perform feature engineering on the execution result data of the preprocessed test cases to extract the execution features of the test cases; The selected machine learning model is trained according to the execution characteristics of the extracted test cases and the set test objectives to obtain a test case optimization model; The execution result of the input test case is predicted based on the test case optimization model, the predicted execution result is analyzed, and the input test case is optimized according to the analysis result to obtain an optimized test case.
[0071] Optionally, the collecting of the test case execution result data and preprocessing the collected test case execution result data specifically includes: Collect and store the execution results, execution time and exception information of the test cases during the test process, and obtain the execution result data of the test cases after statistical analysis; The execution result data of the test case is cleaned, deduplicated and formatted to obtain the execution result data of the preprocessed test case.
[0072] Optionally, the collecting and storing the execution results, execution time and exception information of the test cases during the test process, and obtaining the execution result data of the test cases after statistical analysis, specifically includes: Defining the test case, determining the test steps, expected results and test data of the test case; The test case is tested based on a test management tool, and the test case identification, execution result, execution time and abnormal information during the test process are collected and stored, and the execution result data of the test case is obtained after statistical analysis.
[0073] Optionally, the performing feature engineering processing on the execution result data of the preprocessed test case to extract the execution features of the test case specifically includes: Extracting the path length and branch conditions of the test case during execution, identifying and recording repeated steps, and obtaining the execution path characteristics of the test case; Record the pass status, error type, and execution result characteristics of the test case, and count the number of failures and failed steps to obtain the execution result characteristics of the test case; The total execution time, average execution time, maximum execution time and minimum execution time of the test case are calculated, and the timed-out test case is detected to obtain the execution time characteristics of the test case.
[0074] Optionally, the step of training the selected machine learning model according to the extracted execution characteristics of the test case and the set test objectives to obtain the test case optimization model specifically includes: Determine the test target, and select a corresponding machine learning model according to the test target and the execution characteristics of the extracted test case; Performing data segmentation on the execution result data of the preprocessed test cases to obtain a training set, a validation set, and a test set; Training the selected machine learning model based on preset hyperparameters and the training set, evaluating model performance using the validation set, and adjusting hyperparameters to optimize performance; An evaluation indicator is selected according to the test objective, and the test case optimization model is obtained after optimization based on the evaluation result.
[0075] Optionally, the predicting the execution result of the input test case based on the test case optimization model and analyzing the predicted execution result specifically includes: Based on the test case optimization model, predicting the execution result of the test case to obtain the predicted execution result of the test case; According to the prediction execution results, key factors affecting the prediction results of the test cases are identified, the accuracy and reliability of the prediction results are checked, and the test cases are classified and sorted according to the prediction results.
[0076] Optionally, optimizing the input test case according to the analysis result to obtain an optimized test case specifically includes: According to the key factors, the classification and sorting of the test cases, redundant test cases are deleted, the test coverage is adjusted, and the execution order of the test cases is optimized to obtain the optimized test cases.
[0077] The present invention also provides a computer-readable storage medium, wherein the computer-readable storage medium stores an artificial intelligence-based test case optimization program, and when the artificial intelligence-based test case optimization program is executed by a processor, the steps of the artificial intelligence-based test case optimization method as described above are implemented.
[0078] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal. In the absence of further restrictions, an element defined by the sentence "includes a ..." does not exclude the existence of other identical elements in the process, method, article or terminal including the element.
[0079] Of course, those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware (such as a processor, a controller, etc.) through a computer program, and the program can be stored in a computer-readable storage medium that can be read by a computer, and the program can include the processes of the above-mentioned method embodiments when executed. The computer-readable storage medium can be a memory, a disk, an optical disk, etc.
[0080] It should be understood that the application of the present invention is not limited to the above examples. For ordinary technicians in this field, improvements or changes can be made based on the above description. All these improvements and changes should fall within the scope of protection of the claims attached to the present invention.
Claims
1. A test case optimization method based on artificial intelligence, characterized in that: The test case optimization method based on artificial intelligence includes: Collecting test case execution result data and preprocessing the collected test case execution result data; Perform feature engineering on the execution result data of the preprocessed test cases to extract the execution features of the test cases; The selected machine learning model is trained according to the execution characteristics of the extracted test cases and the set test objectives to obtain a test case optimization model; The execution result of the input test case is predicted based on the test case optimization model, the predicted execution result is analyzed, and the input test case is optimized according to the analysis result to obtain an optimized test case.
2. The test case optimization method based on artificial intelligence according to claim 1, characterized in that: The collecting of the test case execution result data and preprocessing the collected test case execution result data specifically includes: Collect and store the execution results, execution time and exception information of the test cases during the test process, and obtain the execution result data of the test cases after statistical analysis; The execution result data of the test case is cleaned, deduplicated and formatted to obtain the execution result data of the preprocessed test case.
3. The test case optimization method based on artificial intelligence according to claim 2, characterized in that: The collection and storage of the execution results, execution time and exception information of the test cases during the test process, and the statistical analysis to obtain the execution result data of the test cases, specifically includes: Defining the test case, determining the test steps, expected results and test data of the test case; The test case is tested based on a test management tool, and the test case identification, execution result, execution time and abnormal information during the test process are collected and stored, and the execution result data of the test case is obtained after statistical analysis.
4. The test case optimization method based on artificial intelligence according to claim 1, characterized in that: The feature engineering process is performed on the execution result data of the preprocessed test case to extract the execution features of the test case, specifically including: Extracting the path length and branch conditions of the test case during execution, identifying and recording repeated steps, and obtaining the execution path characteristics of the test case; Record the pass status, error type, and execution result characteristics of the test case, and count the number of failures and failed steps to obtain the execution result characteristics of the test case; The total execution time, average execution time, maximum execution time and minimum execution time of the test case are calculated, and the timed-out test case is detected to obtain the execution time characteristics of the test case.
5. The test case optimization method based on artificial intelligence according to claim 1, characterized in that: The step of training the selected machine learning model according to the extracted execution characteristics of the test case and the set test objectives to obtain the test case optimization model specifically includes: Determine the test target, and select a corresponding machine learning model according to the test target and the execution characteristics of the extracted test case; Performing data segmentation on the execution result data of the preprocessed test cases to obtain a training set, a validation set, and a test set; Training the selected machine learning model based on preset hyperparameters and the training set, evaluating model performance using the validation set, and adjusting hyperparameters to optimize performance; An evaluation indicator is selected according to the test objective, and the test case optimization model is obtained after optimization based on the evaluation result.
6. The test case optimization method based on artificial intelligence according to claim 1, characterized in that: The step of predicting the execution result of the input test case based on the test case optimization model and analyzing the predicted execution result specifically includes: Based on the test case optimization model, predicting the execution result of the test case to obtain the predicted execution result of the test case; According to the prediction execution results, key factors affecting the prediction results of the test cases are identified, the accuracy and reliability of the prediction results are checked, and the test cases are classified and sorted according to the prediction results.
7. The test case optimization method based on artificial intelligence according to claim 6, characterized in that: The step of optimizing the input test case according to the analysis result to obtain the optimized test case specifically includes: According to the key factors, the classification and sorting of the test cases, redundant test cases are deleted, the test coverage is adjusted, and the execution order of the test cases is optimized to obtain the optimized test cases.
8. A test case optimization system based on artificial intelligence, characterized in that: The test case optimization system based on artificial intelligence includes: A data processing module, used to collect the execution result data of the test cases and pre-process the collected execution result data of the test cases; The feature extraction module is used to perform feature engineering processing on the execution result data of the preprocessed test cases to extract the execution features of the test cases; A model training module is used to train the selected machine learning model according to the execution characteristics of the extracted test cases and the set test objectives to obtain a test case optimization model; The test case optimization module is used to predict the execution result of the input test case based on the test case optimization model, analyze the predicted execution result, and optimize the input test case according to the analysis result to obtain an optimized test case.
9. A terminal, characterized in that: The terminal includes: a memory, a processor, and an artificial intelligence-based test case optimization program stored in the memory and executable on the processor. When the artificial intelligence-based test case optimization program is executed by the processor, the steps of the artificial intelligence-based test case optimization method as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores an artificial intelligence-based test case optimization program, and when the artificial intelligence-based test case optimization program is executed by a processor, the steps of the artificial intelligence-based test case optimization method as described in any one of claims 1-7 are implemented.
Citation Information
Cited By
Computer testing method and system based on machine learning
CN119739643A
Computer testing method and system based on machine learning
CN119739643B
Test case optimization method and device based on machine learning and medium
CN121705167A