Software testing method and device, equipment and medium
Through target test analysis model and natural language processing technology, automated test script adjustment and optimization solve the problem of traditional automated test system being sensitive to interface and environment changes, improve test coverage and stability, and reduce maintenance costs and integration difficulty.
Patent Information
- Application Number
- CN202411030595.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-15
AI Technical Summary
The design and deployment of traditional automated test systems requires a lot of time and resources, and is sensitive to changes in software interfaces and environments, resulting in test fragility and high maintenance costs, as well as difficulties in integrating different tools and systems.
Use the target test analysis model to learn the test goals and functional relationships of different environments and interfaces through thinking chain fine-tuning and pre-training models, generate automated test scripts, and adjust the scripts through log data and execution results, and perform natural language processing and pattern recognition to improve testing Coverage and quality.
It reduces sensitivity to interface and environment changes, reduces the need to rewrite test scripts, improves test stability and coverage, reduces initial and maintenance costs, and enhances the ability to work together with different tools and systems.
Smart Images

Figure CN118779244A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software testing, and in particular to a software testing method, device, equipment and medium. Background Art
[0002] The design and deployment of traditional automated testing systems and methods require a lot of time and resources, and require the writing and maintenance of test scripts, configuration of test environments, and integration of test tools, resulting in high initial costs. Moreover, as the software is constantly updated and changed, test scripts and test data also need to be continuously maintained and updated, which greatly increases maintenance costs and may result in insufficient test coverage or reduced test effectiveness. In addition, when the user interface (UI) or operating environment of the software changes, the automated test script may not work properly and needs to be rewritten or adjusted. Therefore, traditional automated testing is sensitive to interface changes and environmental changes, resulting in test fragility, and different automated testing tools and systems are difficult to integrate, especially in large software projects, where the collaborative work of various testing tools and platforms will face challenges.
[0003] It can be seen that when faced with specific scenarios such as specific usage situations or usage environments encountered in automated testing, how to automatically and accurately adjust the test scripts to improve test case coverage and test data quality is a problem that technical personnel in this field need to solve. Summary of the invention
[0004] The purpose of the embodiments of the present invention is to provide a software testing method, apparatus, equipment and medium, which can automatically and accurately adjust the test script when facing specific scenarios such as specific usage conditions or usage environments encountered in automated testing, thereby improving test case coverage and test data quality.
[0005] In order to solve the above technical problems, an embodiment of the present invention provides a software testing method, comprising:
[0006] The test task is input into the target test analysis model so as to generate a target test script corresponding to the test task through the target test analysis model; wherein the test task includes a test target or a test function, a test environment, and a test interface; the target test analysis model is a model obtained by using a thinking chain fine-tuning method and learning the correspondence between the test targets or test functions in different test environments and different test interfaces and the corresponding test scripts through a pre-training model;
[0007] Executing the target test script through the target test analysis model, monitoring and collecting log data and test execution results generated during the execution process, so as to adjust the target test script output by the target test analysis model using the log data and the test execution results;
[0008] The target test analysis model is used to perform natural language processing and script pattern recognition on the log data to obtain corresponding test analysis results.
[0009] Optionally, before inputting the test task into the target test analysis model, the process further includes:
[0010] Obtaining a data training set; wherein the data training set includes training tasks and corresponding training scripts for different test environments, different test interfaces, and different boundary conditions;
[0011] Constructing a triple according to the training task, the thought chain, and the training script; wherein the thought chain is a natural language reasoning process from the training task to the training script flow;
[0012] The triples used for model fine-tuning training, the model parameters of the pre-trained model, and the data verification set used for model evaluation are saved through the model training evaluation class of the preset natural language processing library;
[0013] Load the triples in the model training evaluation class and the model parameters of the pre-trained model, then input the training tasks and the thought chain in the triples into the pre-trained model to obtain the expected probabilities corresponding to the corresponding model output results, and perform thought chain fine-tuning on the expected probabilities corresponding to the training scripts in the triples in the model output results to obtain the target test analysis model including the test script generation layer after the model parameters are updated;
[0014] The target test analysis model including the test script generation layer is evaluated by using the data verification set of the model training evaluation class, and the target test analysis model is evaluated according to the model verification result to obtain a target test analysis model that passes the evaluation.
[0015] Optionally, constructing a triplet according to the training task, the thought chain, and the training script includes:
[0016] According to each of the training tasks, each of the thought chains, and each of the training scripts, corresponding triples are constructed respectively, and then all triples are counted to obtain a corresponding triple set; the triple set is ;in, Indicates training tasks, as the input information of triples, Indicates training scripts, as the output information of triples, Indicates A chain of thoughts, as a natural language reasoning process from input information to output information in a triple, , is a set of positive integers;
[0017] Correspondingly, the triples in the model training evaluation class and the model parameters of the pre-trained model are loaded, and then the training tasks and the thought chains in the triples are input into the pre-trained model to obtain the expected probabilities corresponding to the corresponding model output results, and the thought chains are fine-tuned for the expected probabilities corresponding to the training scripts in the triples in the model output results to obtain the target test analysis model including the test script generation layer after the model parameters are updated, including:
[0018] Load the triplet in the model training evaluation class and the model parameters of the pre-trained model, and then input the training task and the thinking chain in the triplet into the pre-trained model to obtain P ( A | [ Q , d , i ] ) = ∏ i = 1 | A | f PLM ( a i | [ Q , d , i ] ) The expected probability of the corresponding model output results; among them, A = [ a 1 ,..., a n ] , which represents the amount of information generated by a training text at each reasoning stage Different model output results; represents the model parameters of the pre-trained model, represents a probabilistic language model, Indicates The expected output of the reasoning process, represents the total number of reasoning processes;
[0019] The loss value is calculated based on the model output result carrying the expected probability and the expected probability corresponding to the training script, and the gradient of the pre-trained model is reversely calculated using the loss value calculation result, so as to use the optimizer to update the model parameters according to the gradient, and obtain the target test analysis model including the test script generation layer after the model parameters are updated.
[0020] Optionally, obtaining a data training set includes:
[0021] Remove noise data and duplicate data from the collected initial data training set to obtain a cleaned data training set containing different test environments, different test interfaces, and different boundary conditions;
[0022] Performing data segmentation on each cleaned text data in the cleaned data training set to obtain segmented word units;
[0023] Perform vector conversion on each word unit to obtain the corresponding word vector, and detect whether the initial sequence length of each word vector is consistent with the preset sequence length;
[0024] If the initial sequence length is inconsistent with the preset sequence length, adjusting the initial sequence length according to a preset truncation rule or a preset filling rule to obtain a target word vector with a target sequence length consistent with the preset sequence length;
[0025] If the initial sequence length is consistent with the preset sequence length, the word vector corresponding to the initial sequence length is used as the target word vector;
[0026] Count all target word vectors and output them as data training set.
[0027] Optionally, the software testing method further includes:
[0028] The test script execution layer and test result analysis layer of the training target test analysis model;
[0029] The test script execution layer is used to execute multiple test scripts, and the test result analysis layer is used to perform test analysis on log data generated when the test script execution layer executes the test scripts.
[0030] Optionally, performing natural language processing and script pattern recognition on the log data by using the target test analysis model to obtain corresponding test analysis results includes:
[0031] Understanding the relevant meanings expressed by each of the log data through the test result analysis model, and finding the test trends and abnormal script patterns in the test process from the relevant meanings expressed by each of the log data through pattern recognition technology;
[0032] The test trends and abnormal script patterns are visualized using data analysis tools to obtain corresponding test analysis results.
[0033] Optionally, the software testing method further includes:
[0034] The test analysis results are fed back to the target test analysis model so as to utilize the test analysis results to optimize the execution process of the test script generation layer in the target test analysis model, and to update and maintain the target test analysis model and model parameters according to a preset time period.
[0035] In a second aspect, an embodiment of the present invention provides a software testing device, including:
[0036] A script generation module is used to input a test task into a target test analysis model so as to generate a target test script corresponding to the test task through the target test analysis model; wherein the test task includes a test target or a test function, a test environment, and a test interface; the target test analysis model is a model obtained by using a thinking chain fine-tuning method and learning the correspondence between test targets or test functions in different test environments and different test interfaces and corresponding test scripts through a pre-training model;
[0037] A script execution module, used to execute the target test script through the target test analysis model, monitor and collect log data and test execution results generated during the execution process, so as to adjust the target test script output by the target test analysis model using the log data and the test execution results;
[0038] The test analysis module is used to perform natural language processing and script pattern recognition on the log data through the target test analysis model to obtain corresponding test analysis results.
[0039] In a third aspect, an embodiment of the present invention provides an electronic device, including:
[0040] Memory for storing computer programs;
[0041] A processor is used to execute the computer program to implement the steps of the software testing method disclosed above.
[0042] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the software testing method disclosed above are implemented.
[0043] It can be seen that the present application discloses a software testing method, including: inputting a test task into a target test analysis model, so as to generate a target test script corresponding to the test task through the target test analysis model; wherein, the test task includes a test target or a test function, a test environment, and a test interface; the target test analysis model is a model obtained after using a thinking chain fine-tuning method and learning the correspondence between test targets or test functions in different test environments and different test interfaces and corresponding test scripts through a pre-training model; executing the target test script through the target test analysis model, monitoring and collecting the log data and test execution results generated during the execution process, so as to use the log data and the test execution results to adjust the target test script output by the target test analysis model; performing natural language processing and script pattern recognition on the log data through the target test analysis model to obtain corresponding test analysis results.
[0044] It can be seen from the above technical solution that the test script can be automatically adjusted according to the update and change of the software, reducing the sensitivity to interface changes and environmental changes, reducing the situation where the test script cannot work properly due to changes and needs to be rewritten or significantly adjusted, and enhancing the stability and reliability of the test. Using log data and test execution results to adjust the test script can improve the coverage of test cases and the quality of test data, thereby improving the test effect. Compared with the problem of difficult integration of different automated testing tools and systems in traditional methods, the present invention performs better in the collaborative work between different testing links and tools. There is no need to invest a lot of time and resources to write and maintain test scripts, configure test environments, and integrate test tools, which reduces initial costs and ongoing maintenance costs. Natural language processing and script pattern recognition of log data can analyze test situations more intelligently, providing a basis for further optimizing tests. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0046] Figure 1 A flowchart of a software testing method provided by an embodiment of the present invention;
[0047] Figure 2 A principle diagram of the thinking chain fine-tuning technology of an automated testing method based on the pre-training model fine-tuning technology Guanaco provided in an embodiment of the present invention;
[0048] Figure 3 A flow chart of an automated testing method based on the pre-trained model fine-tuning technology Guanaco provided in an embodiment of the present invention;
[0049] Figure 4 A schematic diagram of an automated testing system based on the pre-trained model fine-tuning technology Guanaco provided in an embodiment of the present invention;
[0050] Figure 5 A schematic diagram of the structure of a software testing device provided by an embodiment of the present invention;
[0051] Figure 6 A diagram of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] The terms "including" and "having" in the specification of the present invention and the above-mentioned drawings, as well as any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may include steps or units that are not listed.
[0054] The design and deployment of traditional automated testing systems and methods require a lot of time and resources, and require the writing and maintenance of test scripts, configuration of test environments, and integration of test tools, resulting in high initial costs. Moreover, as the software is constantly updated and changed, test scripts and test data also need to be continuously maintained and updated, which greatly increases maintenance costs and may result in insufficient test coverage or reduced test effectiveness. In addition, when the user interface (UI) or operating environment of the software changes, the automated test script may not work properly and needs to be rewritten or adjusted. Therefore, traditional automated testing is sensitive to interface changes and environmental changes, resulting in test fragility, and different automated testing tools and systems are difficult to integrate, especially in large software projects, where the collaborative work of various testing tools and platforms will face challenges.
[0055] To this end, the present invention provides a software testing solution that can automatically and accurately adjust the test script when faced with specific scenarios such as specific usage conditions or usage environments encountered in automated testing, thereby improving test case coverage and test data quality.
[0056] In order to enable those skilled in the art to better understand the solution of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0057] Next, a software testing method provided by an embodiment of the present invention is described in detail. Figure 1 A software testing method provided by an embodiment of the present invention includes:
[0058] Step S11: Input the test task into the target test analysis model so as to generate a target test script corresponding to the test task through the target test analysis model; wherein, the test task includes a test target or test function, a test environment, and a test interface; the target test analysis model is a model obtained by using a thinking chain fine-tuning method and learning the correspondence between test targets or test functions in different test environments and different test interfaces and corresponding test scripts through a pre-training model.
[0059] In this embodiment, before the test task is input into the target test analysis model, it also includes: obtaining a data training set; wherein the data training set includes training tasks and corresponding training scripts for different test environments, different test interfaces, and different boundary conditions; wherein obtaining the data training set includes: removing noise data and duplicate data from the collected initial data training set to obtain a cleaned data training set including different test environments, different test interfaces, and different boundary conditions; performing data segmentation on each cleaned text data in the cleaned data training set to obtain segmented word units; performing vector conversion on each word unit to obtain a corresponding word vector, and detecting whether the initial sequence length of each word vector is consistent with the preset sequence length; if the initial sequence length is inconsistent with the preset sequence length, adjusting the initial sequence length according to a preset truncation rule or a preset filling rule to obtain a target word vector with a target sequence length consistent with the preset sequence length; if the initial sequence length is consistent with the preset sequence length, taking the word vector corresponding to the initial sequence length as the target word vector; counting all target word vectors and outputting them as a data training set. It is understandable that before inputting the test task into the target test analysis model, the target test analysis model needs to be trained first. The steps of training the target test analysis model are: obtaining training data, using the training data to train and fine-tune the pre-trained model, evaluating the trained test analysis model, and taking the model that meets the evaluation requirements as the target test analysis model. Specifically, collect and organize the data training sets required for the task, combine the data with the pre-trained model Guanaco (a model based on the LLaMA model using the QLoRA fine-tuning technology), and establish an optimization model capable of generating test cases based on the thinking chain fine-tuning technology driven by data and knowledge fusion; wherein, use machine learning algorithms to process and clean the initial data training sets collected for specific tasks: It should be noted that specific tasks and specific scenarios are related. The "specific tasks" mentioned refer to specific test goals or functions that need to be completed. These specific tasks are associated with interface changes, sensitive environmental changes, and specific scenarios. Because each task may be affected by changes in the interface and environment, it needs to be adjusted and optimized according to these changes. Specific tasks specifically include different modules, such as functional modules, input conditions and expected output modules, boundary conditions and abnormal situation modules.
[0060] Step 1-1: Data cleaning, using principal component analysis to remove noise and repeated initial data training samples, to ensure that the cleaned data training set covers various scenarios and situations in script automation testing; among them, the initial data training set generally includes: test task parameters: such as input data, expected output, test script, etc.; For example: the data training data set for login function testing may include valid and invalid username and password combinations, as well as expected login success or failure messages. Various scenarios include functional scenarios (login function, registration function, payment function, search function, etc.), interface scenarios (multi-browser compatibility, multi-device compatibility, responsive design testing), performance scenarios (loading time testing, stress testing, resource consumption testing), various situations include input situations (valid input, invalid input, boundary value input) abnormal situations (network abnormalities, server abnormalities, client abnormalities), and environmental changes (operating system changes, browser version changes, hardware configuration changes).
[0061] Step 1-2: Data preprocessing, split the text data into word units, use the pre-trained Word2Vec to convert the words into vectors, and finally convert the processed text data into a fixed-length sequence, truncate and fill it to meet the model input requirements, and count all the text data that meet the model input requirements to obtain a data set; among them, the text data segmentation is to split the continuous text into individual words. For example, "The weather is so good today" may be segmented into "today", "weather", and "good". Then use Word2Vec (Word to Vector, a related model used to generate word vectors) to convert the segmented words into vectors. Word2Vec is a word vector model that can generate a fixed-dimensional vector representation for each word. These vectors usually capture the semantic relationship between words, converting words from discrete symbols to continuous numerical vectors, which is easier for the model to calculate and learn. Truncation or padding is a common technique in Natural Language Processing (NLP): truncation includes Pre-truncation, which is to delete some words from the beginning of the text to make it reach a fixed length, Post-truncation, which is to delete some words from the end of the text to meet the fixed length requirement; padding includes adding, which is to add some specific padding values (such as zero vectors) at the beginning of the text to make the text length reach a fixed value, Post-padding, which is to add padding values at the end of the text to reach a fixed length, and Mixed-padding, which is to combine pre-padding and post-padding methods to pad according to certain rules. For example, if the model requires the input sequence length to be 10, and the length of a certain text after segmentation and conversion to a vector is 15. If post-truncation is used, 5 words at the end of the text will be deleted; if post-padding is used, 5 zero vectors will be added to the end of the text.
[0062] Step 1-3: Data set division: divide the data set into data training set, data validation set and data test set in a ratio of 8:1:1.
[0063] In this embodiment, after obtaining the data training set, a triple is constructed according to the training task, the thinking chain, and the training script; wherein the thinking chain is a natural language reasoning process from the training task to the training script flow; the triple used for model fine-tuning training, the model parameters of the pre-trained model, and the data verification set for model evaluation are saved through the model training evaluation class of the preset natural language processing library; the triple and the model parameters of the pre-trained model in the model training evaluation class are loaded, and then the training task and the thinking chain in the triple are input into the pre-trained model to obtain the expected probabilities corresponding to the corresponding model output results, and the thinking chain is fine-tuned for the expected probabilities in the model output results corresponding to the training script in the triple to obtain the target test analysis model including the test script generation layer after the model parameters are updated; the target test analysis model including the test script generation layer is model evaluated using the data verification set of the model training evaluation class, and the target test analysis model is evaluated according to the model verification result to obtain a target test analysis model that passes the evaluation. Specifically, corresponding triples are constructed according to each of the training tasks, each of the thought chains, and each of the training scripts, and then all triples are counted to obtain a corresponding triple set; the triple set is ;in, Indicates training tasks, as the input information of triples, Indicates training scripts, as the output information of triples, Indicates A chain of thoughts, as a natural language reasoning process from input information to output information in a triple, , is a positive integer set, and then loads the triples in the model training evaluation class and the model parameters of the pre-trained model, and then inputs the training tasks and the thinking chain in the triples into the pre-trained model to obtain P ( A | [ Q , d , i ] ) = ∏ i = 1 | A | f PLM ( a i | [ Q , d , i ] ) The expected probability of the corresponding model output results; among them, A = [ a 1 ,..., a n ] , which represents the amount of information generated by a training text at each reasoning stage Different model output results; represents the model parameters of the pre-trained model, represents a probabilistic language model, Indicates The expected output of the reasoning process, Represents the total number of inference processes; calculates the loss value according to the model output result carrying the expected probability and the expected probability corresponding to the training script, and uses the loss value calculation result to reversely calculate the gradient of the pre-trained model, so as to use the optimizer to update the model parameters according to the gradient, and obtain the target test analysis model containing the test script generation layer after the model parameters are updated.
[0064] It is understandable that if Figure 2 As shown in Figure 1, when constructing the test script generation layer, it includes the reasoning stage and the construction prompt fine-tuning. Specifically, the reasoning stage is a triple consisting of input, thought chain and output. The input is recorded as the question example Q, the thought chain is the intermediate natural language reasoning step in the process of obtaining the final output result, recorded as the principle R, and the output is the expected answer A, recorded as the prompt ; Construct hint fine-tuning: Since the reasoning process is given, it can be assumed that there are different expected answers at different stages of reasoning, that is, A = [ a 1 ,..., a n ] , which represents the amount of information generated by a training text at each reasoning stage Different model output results. An explanatory intermediate step is introduced to complete the inference calculation within the model. The specific formula is as follows: P ( A | [ Q , d , i ] ) = ∏ i = 1 | A | f PLM ( a i | [ Q , d , i ] ) .
[0065] According to the Bayesian formula, we can conclude that:
[0066] P ( A | [ Q , d ] ) = P ( A | [ Q , R , d ] ) P ( R | [ d , Q ] ) ;
[0067] P ( R | [ d , Q ] ) = ∏ i = 1 | R | f PLM ( r i | [ Q , d , r < i ] ) ;
[0068] P ( A | [ Q , d , R ] ) = ∏ j = 1 | A | f PLM ( a i | [ Q , d , R , a < j ] ) ;
[0069] in, Indicates the first step in the chain of thought process in the reasoning stage Reasoning before the position, In the sequence A, All elements before position .
[0070] In this way, after all the reasoning stages, test scripts covering various scenarios and boundary conditions can be generated. The definitions of various scenarios and boundary conditions are based on the test tasks:
[0071] 1. Functional scenarios: different functional modules of the software, such as login, registration, and payment;
[0072] 2. Input scenarios: different combinations of input data, such as valid and invalid inputs;
[0073] 3. Environmental scenarios: different test environments, such as operating systems and browsers;
[0074] Boundary conditions: input boundary values (such as maximum and minimum values) and abnormal conditions (such as incorrect input).
[0075] It can be seen that when building the test script generation layer (Guanaco fine-tuning module), the model is fine-tuned and evaluated. The Trainer class is used for fine-tuning, the data training set is loaded, the training parameters are defined, and the trainer is initialized to implement model training. Then, the fine-tuned model is evaluated on the validation set and saved for subsequent use. In this way, according to project requirements and code changes, the use cases that need to be tested are defined, and the fine-tuned Guanaco module is used to automatically generate test scripts covering various scenarios and boundary conditions. In this way, by automatically generating test scripts, the time and workload of manual writing are reduced, the test efficiency is improved, and Guanaco's API (Application Programming Interface) and command line tools are called for testing.
[0076] In this embodiment, after constructing the test script generation layer, the test script execution layer and the test result analysis layer of the target test analysis model are also trained; wherein the test script execution layer is used to execute multiple test scripts, and the test result analysis layer is used to test and analyze the log data generated when the test script execution layer executes the test script. It can be understood that the test script execution layer (test execution module) is further constructed, and the test script execution layer is constructed by integrating the existing automated test framework to automatically execute the generated test script. In this way, by calling the test script automatically generated by Guanaco, the system under test is fully automated tested, and the logs and outputs during the test process are monitored and recorded, which can quickly adapt to changes in code and requirements, adjust the test content in time, and construct a test result analysis layer (test result analysis module) to collect the log data generated during the test execution process, and use the pre-trained model and data analysis tools to automatically analyze the collected data to find out the problems and abnormalities in the test, and then use Guanaco and the data analysis tool to generate a test report, and visualize it in the form of charts to find out the problems and abnormalities in the test, and check the test results and coverage. Among them, the data analysis tool can be Tableau, Matplotlib, etc.
[0077] When the target test analysis model training and evaluation is completed, the test task will be input into the target test analysis model so that the target test script corresponding to the test task can be directly and automatically generated through the target test analysis model. It should be noted that since the automated testing process is sensitive to interface changes and environmental changes, it is necessary to obtain test tasks for specific scenarios and associate the above changes with the test tasks. Specific scenarios refer to specific situations or usage environments encountered in automated testing. For example, different test scenarios include login function testing, payment processing testing, and interface compatibility testing.
[0078] In addition, the process of inputting the test task into the trained target test analysis model can also be achieved by preprocessing and extracting features of the input test task. For example, for the description of the test environment and test interface, extract key feature words or parameters, and then combine and encode these extracted features with the test target or test function to form a more structured and standardized input format, which is then input into the target test analysis model.
[0079] Assume that the original test environment description is "tested in an environment with Windows 10 operating system, Intel Core i7 processor, and 8GB memory". After preprocessing and feature extraction, it is converted into a structured form such as "operating system: Windows 10, processor: Intel Core i7, memory: 8GB". The advantage of this is that it can make the input information clearer and easier for the model to understand, and improve the accuracy and efficiency of the model to generate the target test script.
[0080] Reference Figure 3As shown, the present invention discloses the entire construction process and execution process of a target test analysis model, which are specifically as follows: S1: Constructing a Guanaco fine-tuning module, collecting and organizing the data sets required for a specific task, combining the data with the pre-trained Guanaco model, and establishing an optimization model capable of generating high-quality test cases based on the thinking chain fine-tuning technology driven by data and knowledge fusion; S2: Constructing a test script generation module, defining the use cases to be tested according to project requirements and code changes, and using the fine-tuned Guanaco model to automatically generate test scripts covering various scenarios and boundary conditions according to project requirements; S3: Constructing a test execution module, automatically executing the generated test scripts by integrating the existing automated testing framework; S4: Constructing a test result analysis module, collecting the log data generated during the test execution process, and using the pre-trained model and data analysis tools to automatically analyze the collected data to find out the problems and abnormalities in the test; S5: Constructing an optimization and maintenance module, feeding back the test results and analysis data to the Guanaco fine-tuning module, further optimizing the model, script generation and execution process, and regularly updating and maintaining the Guanaco model and its fine-tuning parameters.
[0081] Correspondingly, such as Figure 4 As shown, Figure 4 A schematic diagram of an automated testing system based on the pre-trained model fine-tuning technology Guanaco is provided in the present invention, and the system includes a Guanaco fine-tuning module, a test script generation module, a test execution module, a test result analysis module, and an optimization and maintenance module. The Guanaco fine-tuning module optimizes the pre-trained model to a specific automated testing task through fine-tuning technology, performs optimization based on the pre-trained model, and uses prompt fine-tuning to solve semantic differences and overfitting problems, thereby improving the adaptability of the pre-trained model to automated testing tasks; the test script generation module uses the fine-tuned pre-trained model to automatically generate high-quality test scripts, and reduces the tedious work of manually writing test scripts through automated means, thereby improving the coverage and accuracy of test cases. The large-model automated testing based on Guanaco solves the tedious problems of manually writing and maintaining test scripts, and can make precise adjustments for specific scenarios without affecting the overall test framework, thereby improving the coverage of test cases and the quality of test data. It also automatically analyzes test results, quickly adapts to code and demand changes, and significantly improves the efficiency of regression testing and cross-platform testing.
[0082] It can be seen that by automatically generating test cases and parallel testing, the time and effort of manually writing test cases are reduced. The system enhances test coverage, uses the generalization ability of language models to generate test cases covering a wider range of scenarios, including boundary conditions and abnormal conditions, and can adaptively learn and adjust the generated test cases to improve the comprehensiveness of the test. In addition, the automated testing system reduces the dependence on manual testers, reduces labor costs, and can quickly generate and execute test cases, supporting rapid iterative development and testing. The system has strong flexibility and scalability. Based on the fine-tuning technology of pre-trained models, it can be customized according to different projects and requirements to adapt to different testing requirements, and the architecture supports the addition of new test modules and functions, with good scalability. The system can automatically generate detailed test reports, and based on the natural language processing capabilities of pre-trained models, it can intelligently analyze the test results, provide improvement suggestions and risk assessment.
[0083] Step S12: Execute the target test script through the target test analysis model, monitor and collect log data and test execution results generated during the execution process, so as to use the log data and the test execution results to adjust the target test script output by the target test analysis model.
[0084] In this embodiment, the test script generated by the test script generation layer is automatically executed by the test script execution layer of the target test analysis model, and in the process of automatically executing the test script, the log data and test execution results generated by the execution process are monitored and collected, so that the model parameters of the target test analysis model can be reversely adjusted and optimized using the log data and test execution results, that is, the target test script output by the target test analysis model can be adjusted. Therefore, it is possible to quickly adapt to changes in code and requirements, adjust the test content in a timely manner, and ensure the continuity and accuracy of the test process.
[0085] Step S13: performing natural language processing and script pattern recognition on the log data through the target test analysis model to obtain corresponding test analysis results.
[0086] In this embodiment, the test result analysis model is used to understand the relevant meanings expressed by each of the log data, and the pattern recognition technology is used to find the test trend and the abnormal script pattern in the test process from the relevant meanings expressed by each of the log data; the test trend and the abnormal script pattern are visualized using the data analysis tool to obtain the corresponding test analysis results. It can be seen that the test report is generated using Guanaco and the data analysis tool, and is visualized in the form of charts to find out the problems and abnormal situations in the test, and to check the test results and coverage.
[0087] In this embodiment, the test analysis results are fed back to the target test analysis model so that the test analysis results can be used to optimize the execution process of the test script generation layer in the target test analysis model, and the target test analysis model and model parameters are updated and maintained according to a preset time period. It can be understood that the test analysis results are fed back to the Guanaco fine-tuning module through the optimization and maintenance layer in the target test analysis model to further optimize the automated test scripts and Guanaco configurations, update test cases, and regularly check and maintain the test environment and tools to ensure their normal operation, and regularly update and maintain the Guanaco model and its fine-tuning parameters.
[0088] It can be seen that the present application discloses a software testing method, including: inputting a test task into a target test analysis model, so as to generate a target test script corresponding to the test task through the target test analysis model; wherein, the test task includes a test target or a test function, a test environment, and a test interface; the target test analysis model is a model obtained after using a thinking chain fine-tuning method and learning the correspondence between test targets or test functions in different test environments and different test interfaces and corresponding test scripts through a pre-training model; executing the target test script through the target test analysis model, monitoring and collecting the log data and test execution results generated during the execution process, so as to use the log data and the test execution results to adjust the target test script output by the target test analysis model; performing natural language processing and script pattern recognition on the log data through the target test analysis model to obtain corresponding test analysis results.
[0089] It can be seen from the above technical solution that the test script can be automatically adjusted according to the update and change of the software, reducing the sensitivity to interface changes and environmental changes, reducing the situation where the test script cannot work properly due to changes and needs to be rewritten or significantly adjusted, and enhancing the stability and reliability of the test. Using log data and test execution results to adjust the test script can improve the coverage of test cases and the quality of test data, thereby improving the test effect. Compared with the problem of difficult integration of different automated testing tools and systems in traditional methods, the present invention performs better in the collaborative work between different testing links and tools. There is no need to invest a lot of time and resources to write and maintain test scripts, configure test environments, and integrate test tools, which reduces initial costs and ongoing maintenance costs. Natural language processing and script pattern recognition of log data can analyze test situations more intelligently, providing a basis for further optimizing tests.
[0090] Reference Figure 5 As shown, Figure 5 A schematic diagram of the structure of a software testing device provided by an embodiment of the present invention includes:
[0091] The script generation module 11 is used to input the test task into the target test analysis model so as to generate a target test script corresponding to the test task through the target test analysis model; wherein the test task includes a test target or a test function, a test environment, and a test interface; the target test analysis model is a model obtained by using a thinking chain fine-tuning method and learning the correspondence between the test targets or test functions in different test environments and different test interfaces and the corresponding test scripts through a pre-training model;
[0092] A script execution module 12, configured to execute the target test script through the target test analysis model, monitor and collect log data and test execution results generated during the execution process, so as to adjust the target test script output by the target test analysis model using the log data and the test execution results;
[0093] The test analysis module 13 is used to perform natural language processing and script pattern recognition on the log data through the target test analysis model to obtain corresponding test analysis results.
[0094] It can be seen that the present invention inputs the test task into the target test analysis model so as to generate the target test script corresponding to the test task through the target test analysis model; wherein the test task includes a test target or test function, a test environment, and a test interface; the target test analysis model is a model obtained by using the thinking chain fine-tuning method and learning the corresponding relationship between the test targets or test functions under different test environments and different test interfaces through the pre-training model; the target test script is executed by the target test analysis model, and the log data and test execution results generated during the execution process are monitored and collected, so as to adjust the target test script output by the target test analysis model using the log data and the test execution results; the log data is subjected to natural language processing and script pattern recognition by the target test analysis model to obtain the corresponding test analysis results. The test script can be automatically adjusted according to the update and change of the software, reducing the sensitivity to interface changes and environmental changes, reducing the situation where the test script cannot work properly due to changes and needs to be rewritten or greatly adjusted, and enhancing the stability and reliability of the test. Using log data and test execution results to adjust the test script can improve the coverage of test cases and the quality of test data, thereby improving the test effect. Compared with the difficulty of integrating different automated testing tools and systems in traditional methods, the present invention performs better in the collaborative work between different testing links and tools. It does not require a lot of time and resources to write and maintain test scripts, configure test environments, and integrate test tools, reducing initial costs and ongoing maintenance costs. It performs natural language processing and script pattern recognition on log data, can analyze test situations more intelligently, and provide a basis for further optimizing tests.
[0095] Figure 6 A structural diagram of an electronic device provided by an embodiment of the present invention, such as Figure 6 As shown, the electronic device includes: a memory 20 for storing a computer program;
[0096] The processor 21 is used to implement the steps of the software testing method in the above embodiment when executing a computer program.
[0097] The electronic device provided in this embodiment may include but is not limited to a smart phone, a tablet computer, a laptop computer or a desktop computer.
[0098] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of digital signal processing (DSP), field-programmable gate array (FPGA), and programmable logic array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a central processing unit (CPU); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a graphics processing unit (GPU), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an artificial intelligence (AI) processor, which is used to process computing operations related to machine learning.
[0099] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include a high-speed random access memory, and a non-volatile memory, such as one or more disk storage devices, flash memory storage devices. In this embodiment, the memory 20 is at least used to store the following computer program 201, wherein, after the computer program is loaded and executed by the processor 21, the relevant steps of the software testing method disclosed in any of the aforementioned embodiments can be implemented. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include but is not limited to data transmitted by an external device received by the electronic device, data collected by its own input and output interface 23, and the like.
[0100] In some embodiments, the electronic device may further include a display screen 22 , an input / output interface 23 , a communication interface 24 , a power source 25 , and a communication bus 26 .
[0101] It is understandable that if the software testing method in the above embodiment is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the current technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, magnetic disk or optical disk and other media that can store program code.
[0102] Based on this, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned software testing method are implemented.
[0103] The above is a detailed introduction to the scheme provided by the embodiment of the present invention. The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same and similar parts between the various embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part description.
[0104] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0105] The above is a detailed introduction to the scheme provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. It should be pointed out that for ordinary technicians in this technical field, without departing from the principle of the present invention, the present invention can also be improved and modified in a number of ways, and these improvements and modifications also fall within the scope of protection of the claims of the present invention.
Claims
1. A software testing method, characterized in that: include: The test task is input into the target test analysis model so as to generate a target test script corresponding to the test task through the target test analysis model; wherein the test task includes a test target or a test function, a test environment, and a test interface; the target test analysis model is a model obtained by using a thinking chain fine-tuning method and learning the correspondence between the test targets or test functions in different test environments and different test interfaces and the corresponding test scripts through a pre-training model; Executing the target test script through the target test analysis model, monitoring and collecting log data and test execution results generated during the execution process, so as to adjust the target test script output by the target test analysis model using the log data and the test execution results; The target test analysis model is used to perform natural language processing and script pattern recognition on the log data to obtain corresponding test analysis results.
2. The software testing method according to claim 1, characterized in that: Before inputting the test task into the target test analysis model, the method further includes: Obtaining a data training set; wherein the data training set includes training tasks and corresponding training scripts for different test environments, different test interfaces, and different boundary conditions; Constructing a triple according to the training task, the thought chain, and the training script; wherein the thought chain is a natural language reasoning process from the training task to the training script flow; The triples used for model fine-tuning training, the model parameters of the pre-trained model, and the data verification set used for model evaluation are saved through the model training evaluation class of the preset natural language processing library; Load the triples in the model training evaluation class and the model parameters of the pre-trained model, then input the training tasks and the thought chain in the triples into the pre-trained model to obtain the expected probabilities corresponding to the corresponding model output results, and perform thought chain fine-tuning on the expected probabilities corresponding to the training scripts in the triples in the model output results to obtain the target test analysis model including the test script generation layer after the model parameters are updated; The target test analysis model including the test script generation layer is evaluated by using the data verification set of the model training evaluation class, and the target test analysis model is evaluated according to the model verification result to obtain a target test analysis model that passes the evaluation.
3. The software testing method according to claim 2, characterized in that: The constructing of a triple according to the training task, the thought chain, and the training script includes: According to each of the training tasks, each of the thought chains, and each of the training scripts, corresponding triples are constructed respectively, and then all triples are counted to obtain a corresponding triple set; the triple set is ;in, Indicates training tasks, as the input information of triples, Indicates training scripts, as the output information of triples, Indicates A chain of thoughts, as a natural language reasoning process from input information to output information in a triple, , is a set of positive integers; Correspondingly, the triples in the model training evaluation class and the model parameters of the pre-trained model are loaded, and then the training tasks and the thought chains in the triples are input into the pre-trained model to obtain the expected probabilities corresponding to the corresponding model output results, and the thought chains are fine-tuned for the expected probabilities corresponding to the training scripts in the triples in the model output results to obtain the target test analysis model including the test script generation layer after the model parameters are updated, including: Load the triplet in the model training evaluation class and the model parameters of the pre-trained model, and then input the training task and the thinking chain in the triplet into the pre-trained model to obtain The expected probability of the corresponding model output results; among them, , which represents the amount of information generated by a training text at each reasoning stage Different model output results; represents the model parameters of the pre-trained model, represents a probabilistic language model, Indicates The expected output of the reasoning process, represents the total number of reasoning processes; The loss value is calculated based on the model output result carrying the expected probability and the expected probability corresponding to the training script, and the gradient of the pre-trained model is reversely calculated using the loss value calculation result, so as to use the optimizer to update the model parameters according to the gradient, and obtain the target test analysis model including the test script generation layer after the model parameters are updated.
4. The software testing method according to claim 2, characterized in that: The step of obtaining a data training set comprises: Remove noise data and duplicate data from the collected initial data training set to obtain a cleaned data training set containing different test environments, different test interfaces, and different boundary conditions; Performing data segmentation on each cleaned text data in the cleaned data training set to obtain segmented word units; Perform vector conversion on each word unit to obtain the corresponding word vector, and detect whether the initial sequence length of each word vector is consistent with the preset sequence length; If the initial sequence length is inconsistent with the preset sequence length, adjusting the initial sequence length according to a preset truncation rule or a preset filling rule to obtain a target word vector with a target sequence length consistent with the preset sequence length; If the initial sequence length is consistent with the preset sequence length, the word vector corresponding to the initial sequence length is used as the target word vector; Count all target word vectors and output them as data training set.
5. The software testing method according to claim 2, characterized in that: Also includes: The test script execution layer and test result analysis layer of the training target test analysis model; The test script execution layer is used to execute multiple test scripts, and the test result analysis layer is used to perform test analysis on log data generated when the test script execution layer executes the test scripts.
6. The software testing method according to claim 5, characterized in that: The target test analysis model is used to perform natural language processing and script pattern recognition on the log data to obtain corresponding test analysis results, including: Understanding the relevant meanings expressed by each of the log data through the test result analysis model, and finding the test trends and abnormal script patterns in the test process from the relevant meanings expressed by each of the log data through pattern recognition technology; The test trends and abnormal script patterns are visualized using data analysis tools to obtain corresponding test analysis results.
7. The software testing method according to any one of claims 1 to 6, characterized in that: Also includes: The test analysis results are fed back to the target test analysis model so as to utilize the test analysis results to optimize the execution process of the test script generation layer in the target test analysis model, and to update and maintain the target test analysis model and model parameters according to a preset time period.
8. A software testing device, characterized in that: include: A script generation module is used to input a test task into a target test analysis model so as to generate a target test script corresponding to the test task through the target test analysis model; wherein the test task includes a test target or a test function, a test environment, and a test interface; the target test analysis model is a model obtained by using a thinking chain fine-tuning method and learning the correspondence between test targets or test functions in different test environments and different test interfaces and corresponding test scripts through a pre-training model; A script execution module, used to execute the target test script through the target test analysis model, monitor and collect log data and test execution results generated during the execution process, so as to adjust the target test script output by the target test analysis model using the log data and the test execution results; The test analysis module is used to perform natural language processing and script pattern recognition on the log data through the target test analysis model to obtain corresponding test analysis results.
9. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to execute the computer program to implement the steps of the software testing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the software testing method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
Cross-platform software compatibility testing and optimizing method
CN119292949A
Test case generation and script optimization method and device based on machine learning
CN120123251A
