Software test case intelligent generation method and system based on improved genetic algorithm
Patent Information
- Application Number
- CN202211233452.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-10
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2042-10-10
AI Technical Summary
Existing software test case generation technologies suffer from low accuracy and low efficiency, heavily relying on manual design, resulting in insufficient test case generation efficiency and an inability to keep pace with the growth rate of software code size.
An improved genetic algorithm is adopted to obtain the initial original test case population, perform optimal evolution processing, including selection, crossover and mutation operations, to generate a valid test case dataset, and generate an invalid and abnormal test case set through mutation operation. The genetic environment features of historical test case data are extracted using automatic semantic analysis.
It improves the intelligence and efficiency of software test case generation, enables the batch generation of high-quality test cases, enhances the accuracy and efficiency of test case generation, adapts to semantic analysis with different professional characteristics, and expands the application scope.
Smart Images

Figure CN115543803B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of software engineering technology, specifically to a method and system for intelligent generation of software test cases based on an improved genetic algorithm. Background Technology
[0002] As information warfare evolves towards a new generation of digitalization, automation, and intelligence, software products are characterized by rapidly changing development needs, a surge in functionality and code size, and significant differentiation in domain characteristics. Meanwhile, to further promote the improvement of enterprise software product quality and better adapt to the challenges of the transformation of software development technology towards new-generation intelligent technologies such as big data, cloud computing, and artificial intelligence, improving the intelligent generation level and accuracy of test cases is gradually becoming a key technical capability for enhancing the efficiency of software testing.
[0003] There are two main traditional methods for designing software test cases. One method is to manually write test content and create test case documents based on the results of software functional requirements analysis, following the requirements of test case design methods such as equivalence class partitioning, boundary value analysis, and guessing. The other method is to build a prototype test case library with similar historical software technical features, and then manually identify and filter the test case features, making appropriate modifications to suit the software system under test.
[0004] However, the above methods mainly rely on manual design of test cases, which is easily affected by the testers' work experience and professional skills, resulting in inconsistent quality and low accuracy of the generated test cases. This makes it more difficult to identify hidden omissions. Furthermore, relying on manual test case design is highly limited by human resources, leading to insufficient test case generation efficiency and a mismatch between the number of test cases and the rapid growth of software code. Therefore, existing software test case generation technologies suffer from low accuracy and low efficiency. Summary of the Invention
[0005] (a) Technical problems to be solved
[0006] To address the shortcomings of existing technologies, this invention provides a method and system for intelligent generation of software test cases based on an improved genetic algorithm, which solves the problems of low accuracy and low efficiency in existing software test case generation technologies.
[0007] (II) Technical Solution
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] Firstly, this invention proposes an intelligent method for generating software test cases based on an improved genetic algorithm, the method comprising:
[0010] Obtain the initial population of original test cases;
[0011] The original test case population is subjected to selective evolutionary processing based on an improved genetic algorithm to generate a dataset of valid test cases and a dataset of invalid and abnormal test cases; the improved genetic algorithm includes adding a mutation operator to the genetic algorithm.
[0012] Preferably, obtaining the initial original use case population includes:
[0013] The genetic environment and genetic parameters are initialized, and based on the automatic semantic analysis method, effective feature fields with genetic environment characteristics that conform to the characteristics of historical test case data are extracted from the historical test case data according to software requirements and interface protocols. Then, the gene sequence of the effective feature fields is constructed by encoding, and the initial generation of original test case population is completed.
[0014] Preferably, the step of performing optimal evolutionary processing on the initial original test case population based on an improved genetic algorithm to generate a valid test case dataset and an invalid and abnormal test case dataset includes:
[0015] S21. Based on the improved genetic algorithm, the selection operator is performed on the first generation of original test case population to obtain the first generation of high-quality test case population. Then, the crossover operator is performed on the first generation of high-quality test case population to obtain the second generation of test case population. Finally, the mutation operator is performed on the second generation of test case population to generate a valid test case dataset.
[0016] S22. Perform mutation operation on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases.
[0017] Preferably, step S21, which involves performing selection operator processing on the initial generation of original test case population based on an improved genetic algorithm to obtain an initial generation of high-quality test case population, then performing crossover operator processing on the initial generation of high-quality test case population to obtain a second generation of test case population, and finally performing mutation operator processing on the second generation of test case population to generate a valid test case dataset, includes:
[0018] The initial high-quality use case population obtained by performing selection operator processing on the initial original use case population includes:
[0019] Step 401: Count the number of lines of code covered by each test case in the initial original test case population, the number of times each line of code is covered, and calculate the fitness of the corresponding line of code based on this information.
[0020] Step 402: Traverse all individuals in the initial original use case population, calculate the fitness evaluation value and the cumulative fitness of all individuals in the population, and then calculate the individual fitness ratio value based on the fitness evaluation value and the cumulative fitness.
[0021] Step 403: Based on the distribution of individual fitness ratios, divide the population distribution into regions according to the individual fitness ratios, and calculate the fitness value intervals of each individual in the population.
[0022] Step 404: Randomly generate a probability value between [0,1) for each individual. By matching the random probability value with the individual fitness partition, select high-quality individuals that meet the fitness partition value range requirements.
[0023] Step 405: The selected individuals are rearranged and combined according to their fitness values to form the initial high-quality use case population.
[0024] The second-generation test case population is obtained by performing crossover operation on the first-generation high-quality test case population, including:
[0025] Step 501: Set the initial crossover probability as the admission condition for crossover operation of individuals in the first generation of high-quality use case population;
[0026] Step 502: Set the number of cross-loop iterations;
[0027] Step 503: Determine whether a crossover operation is required based on the initial crossover probability. If the conditions for a crossover operation to occur are met, proceed to step 504; otherwise, proceed to step 505.
[0028] Step 504: When the crossover condition is met, set the crossover point position according to the crossover comparison value, and perform the exchange operation on the gene segments before and after the crossover point of the two parent test cases to form the offspring test case population.
[0029] Step 505: When the crossover condition is not met, directly copy the genetic data of the parent test case individual to the offspring genes as is.
[0030] Step 506: After the number of cross-loop iterations is completed, a second-generation use case population is formed;
[0031] Performing mutation operator processing on the next-generation test case population to generate a valid test case dataset includes:
[0032] Step 601: Set the initial mutation probability as the admission condition for judging the mutation operation of individuals in the next generation of high-quality test cases.
[0033] Step 602: Set the number of iterations for the mutation loop;
[0034] Step 603: Determine whether a mutation operation is needed based on the initial mutation probability. If the condition for a mutation operation to occur is met, proceed to step 604; otherwise, proceed to step 602.
[0035] Step 604: When the mutation condition is met, set the mutation point position according to the mutation comparison value, select the effective feature value at the corresponding mutation point position from the effective use case gene database, and perform a replacement operation on the gene value of the next generation use case population individual at the mutation point position to form the gene-mutated individual.
[0036] Step 605: After iterating the mutation loop a certain number of times, a population of valid test cases is obtained.
[0037] Preferably, step S22, performing mutation operations on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases, includes:
[0038] Step 701: Identify the gene fragments that need to be mutated;
[0039] Step 702: Based on the value range of the gene fragment, construct a mutant gene library according to the mutation type; the mutation type includes data types such as invalid boundary mutation, abnormal frame format mutation, and garbled code mutation;
[0040] Step 703: Set the number of mutation cycles;
[0041] Step 704: According to the mutation type, select the corresponding mutation gene value from the mutation gene library and replace it with the gene value of the gene fragment to be mutated at each mutation point to form an individual after gene mutation;
[0042] Step 705: After the number of iterations of the mutation cycle is completed, the individual mutations formed are arranged and combined according to the mutation type to form a set of invalid and abnormal test cases.
[0043] Secondly, this invention also proposes an intelligent software test case generation system based on an improved genetic algorithm, the system comprising:
[0044] The initial raw test case population acquisition module is used to acquire the initial raw test case population.
[0045] The test case generation module is used to perform optimal evolutionary processing on the initial original test case population based on an improved genetic algorithm to generate a dataset of valid test cases and a dataset of invalid and abnormal test cases; the improved genetic algorithm includes adding a mutation operator on the basis of the genetic algorithm.
[0046] Preferably, the initial original test case population acquisition module acquires the initial original test case population by including:
[0047] The genetic environment and genetic parameters are initialized, and based on the automatic semantic analysis method, effective feature fields with genetic environment characteristics that conform to the characteristics of historical test case data are extracted from the historical test case data according to software requirements and interface protocols. Then, the gene sequence of the effective feature fields is constructed by encoding, and the initial generation of original test case population is completed.
[0048] Preferably, the test case generation module uses an improved genetic algorithm to perform selective evolutionary processing on the initial original test case population to generate a valid test case dataset and an invalid and abnormal test case dataset, including:
[0049] S21. Based on the improved genetic algorithm, the selection operator is performed on the first generation of original test case population to obtain the first generation of high-quality test case population. Then, the crossover operator is performed on the first generation of high-quality test case population to obtain the second generation of test case population. Finally, the mutation operator is performed on the second generation of test case population to generate a valid test case dataset.
[0050] S22. Perform mutation operation on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases.
[0051] Preferably, step S21, which involves performing selection operator processing on the initial generation of original test case population based on an improved genetic algorithm to obtain an initial generation of high-quality test case population, then performing crossover operator processing on the initial generation of high-quality test case population to obtain a second generation of test case population, and finally performing mutation operator processing on the second generation of test case population to generate a valid test case dataset, includes:
[0052] The initial high-quality use case population obtained by performing selection operator processing on the initial original use case population includes:
[0053] Step 401: Count the number of lines of code covered by each test case in the initial original test case population, the number of times each line of code is covered, and calculate the fitness of the corresponding line of code based on this information.
[0054] Step 402: Traverse all individuals in the initial original use case population, calculate the fitness evaluation value and the cumulative fitness of all individuals in the population, and then calculate the individual fitness ratio value based on the fitness evaluation value and the cumulative fitness.
[0055] Step 403: Based on the distribution of individual fitness ratios, divide the population distribution into regions according to the individual fitness ratios, and calculate the fitness value intervals of each individual in the population.
[0056] Step 404: Randomly generate a probability value between [0,1) for each individual. By matching the random probability value with the individual fitness partition, select high-quality individuals that meet the fitness partition value range requirements.
[0057] Step 405: The selected individuals are rearranged and combined according to their fitness values to form the initial high-quality use case population.
[0058] The second-generation test case population is obtained by performing crossover operation on the first-generation high-quality test case population, including:
[0059] Step 501: Set the initial crossover probability as the admission condition for crossover operation of individuals in the first generation of high-quality use case population;
[0060] Step 502: Set the number of cross-loop iterations;
[0061] Step 503: Determine whether a crossover operation is required based on the initial crossover probability. If the conditions for a crossover operation to occur are met, proceed to step 504; otherwise, proceed to step 505.
[0062] Step 504: When the crossover condition is met, set the crossover point position according to the crossover comparison value, and perform the exchange operation on the gene segments before and after the crossover point of the two parent test cases to form the offspring test case population.
[0063] Step 505: When the crossover condition is not met, directly copy the genetic data of the parent test case individual to the offspring genes as is.
[0064] Step 506: After the number of cross-loop iterations is completed, a second-generation use case population is formed;
[0065] Performing mutation operator processing on the next-generation test case population to generate a valid test case dataset includes:
[0066] Step 601: Set the initial mutation probability as the admission condition for judging the mutation operation of individuals in the next generation of high-quality test cases.
[0067] Step 602: Set the number of iterations for the mutation loop;
[0068] Step 603: Determine whether a mutation operation is needed based on the initial mutation probability. If the condition for a mutation operation to occur is met, proceed to step 604; otherwise, proceed to step 602.
[0069] Step 604: When the mutation condition is met, set the mutation point position according to the mutation comparison value, select the effective feature value at the corresponding mutation point position from the effective use case gene database, and perform a replacement operation on the gene value of the next generation use case population individual at the mutation point position to form the gene-mutated individual.
[0070] Step 605: After iterating the mutation loop a certain number of times, a population of valid test cases is obtained.
[0071] Preferably, step S22, performing mutation operations on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases, includes:
[0072] Step 701: Identify the gene fragments that need to be mutated;
[0073] Step 702: Based on the value range of the gene fragment, construct a mutant gene library according to the mutation type; the mutation type includes data types such as invalid boundary mutation, abnormal frame format mutation, and garbled code mutation;
[0074] Step 703: Set the number of mutation cycles;
[0075] Step 704: According to the mutation type, select the corresponding mutation gene value from the mutation gene library and replace it with the gene value of the gene fragment to be mutated at each mutation point to form an individual after gene mutation;
[0076] Step 705: After the number of iterations of the mutation cycle is completed, the individual mutations formed are arranged and combined according to the mutation type to form a set of invalid and abnormal test cases.
[0077] (III) Beneficial Effects
[0078] This invention provides a method and system for intelligent generation of software test cases based on an improved genetic algorithm. Compared with existing technologies, it has the following advantages:
[0079] 1. This invention first obtains an initial population of original test cases. Then, based on an improved genetic algorithm, it progressively selects, crossovers, and performs mutation operations on the initial population to generate a dataset of valid test cases. Next, it performs mutation operations on the valid test case dataset to generate a set of invalid and anomalous test cases. This invention's batch intelligent generation of valid, invalid, and anomalous test cases solves the problems of existing software test case design and generation heavily relying on manual labor, insufficient test case generation efficiency, mismatch between the volume of test cases and the growth rate of software code size, and low test case accuracy. It improves the intelligence level and efficiency of software test case generation.
[0080] 2. This invention extracts effective feature fields from historical test case data based on automatic semantic analysis, and constructs a gene database of feature parameters in accordance with the protocol format encoding, so as to realize the rapid formation of the initial original test case population and the initialization of the genetic environment, which greatly improves the targeting and efficiency of test data design.
[0081] 3. This invention is based on fitness evaluation of incremental code coverage. It uses an improved genetic algorithm for selection, crossover, and mutation to perform optimal screening and calculation, and generates a batch of effective test case datasets. This effectively improves the accuracy of the evaluation test case data and enables precise screening of test case data that perform well in the genetic process.
[0082] 4. Based on the principle of gene mutation, this invention constructs a mutation model for the effective test case population, simulates the invalid and abnormal ways of gene mutation, and thus completes the supplementation of effective test cases, which together form the core test case data cultivation process, improving the intelligence level and accuracy of test case generation. Attached Figure Description
[0083] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0084] Figure 1 This is a flowchart of the intelligent generation method for software test cases based on an improved genetic algorithm in an embodiment of the present invention;
[0085] Figure 2 This is a flowchart illustrating the process of performing selection operator filtering in an embodiment of the present invention;
[0086] Figure 3 This is a flowchart illustrating the process of performing crossover operator filtering in an embodiment of the present invention;
[0087] Figure 4 This is a flowchart illustrating the process of performing mutation operator screening in an embodiment of the present invention;
[0088] Figure 5 This is a flowchart illustrating the process of screening mutation operators in an embodiment of the present invention. Detailed Implementation
[0089] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are described clearly and completely. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0090] This application provides a method and system for intelligent generation of software test cases based on an improved genetic algorithm, which solves the problems of low accuracy and low efficiency in existing software test case generation technologies, and achieves the goal of intelligently generating test cases.
[0091] The technical solution in this application is to solve the above-mentioned technical problems, and the general idea is as follows:
[0092] To address the problems of existing technologies where software test case design and generation heavily rely on manual processes, resulting in insufficient test case generation efficiency, a mismatch between the number of test cases and the rapid growth of software code, and low test case accuracy, this technical solution first obtains an initial population of original test cases. Then, based on an improved genetic algorithm, the initial population is progressively selected, crossovered, and mutated to generate a dataset of valid test cases. Finally, mutation operations are performed on the valid test case dataset to generate a set of invalid and anomalous test cases. This technical solution ultimately improves the intelligence and efficiency of software test case generation through these methods.
[0093] To better understand the above technical solutions, the following will provide a detailed explanation of the technical solutions in conjunction with the accompanying drawings and specific implementation methods.
[0094] A test case is a description of a specific software product testing task. It reflects the designed plan, methods, techniques, and strategies used in the software testing process. A test case includes the test objective, test environment, input data, test steps, and expected results, ultimately forming a documented record used to verify whether the software requirements are met. Test cases are primarily used in the software testing industry, including integration testing, system testing, and regression testing.
[0095] Example 1:
[0096] Firstly, this invention proposes an intelligent method for generating software test cases based on an improved genetic algorithm, see [link to relevant documentation]. Figure 1 The method includes:
[0097] S1. Obtain the initial population of original test cases;
[0098] S2. Based on the improved genetic algorithm, the initial original test case population is subjected to selective evolution processing to generate a dataset of valid test cases and a dataset of invalid and abnormal test cases; the improved genetic algorithm includes adding a mutation operator on the basis of the genetic algorithm.
[0099] As can be seen, this embodiment first obtains an initial population of original test cases, then uses an improved genetic algorithm to progressively select, crossover, and mutate this population to generate a dataset of valid test cases. Next, mutation operations are performed on the valid test case dataset to generate a set of invalid and anomalous test cases. This embodiment's intelligent batch generation of valid, invalid, and anomalous test cases solves the problems of existing software test case design and generation heavily relying on manual processes, insufficient test case generation efficiency, mismatch between the volume of test cases and the growth rate of software code size, and low test case accuracy. It improves the intelligence level and efficiency of software test case generation.
[0100] The following is in conjunction with the appendix Figure 1-5 The following details the implementation process of an embodiment of the intelligent generation method for software test cases based on an improved genetic algorithm, along with explanations of the specific steps S1-S2.
[0101] Genetic Algorithm (GA) is a computational model that simulates the biological evolutionary process based on natural selection and genetic mechanisms, as described in Darwin's theory of evolution. It's a method for searching for optimal solutions by simulating natural evolution. This algorithm uses mathematical methods and computer simulation to transform the problem-solving process into processes similar to the selection, crossover, and mutation of chromosomes and genes in biological evolution. To improve the efficiency and accuracy of test case generation, the problem of inefficiency in screening due to enumerating parameter combinations must be addressed. Therefore, in this embodiment, we use an improved genetic algorithm to achieve intelligent generation of software test cases. Based on this,
[0102] S1. Obtain the initial population of original test cases.
[0103] The genetic parameters and genetic environment of the genetic algorithm are initialized to form the initial population of original test cases. Custom combinations are set according to software requirements and interface protocols. Based on the content of historical test case data files in the existing historical database, effective feature fields of the genetic environment characteristics that conform to the characteristics of historical test case data are extracted from the historical test case data using automatic semantic analysis. These feature fields include the seed test case (individual in the initial population of original test cases) ID and the business scenario ID. After setting and saving the task configuration parameters, the system automatically constructs the gene sequence of the feature parameters through encoding, and completes the construction of the initial test case population and the initial test case gene library. The genetic environment refers to the operating environment of the intelligent test case generation system, which includes prerequisites, configuration parameters, and basic feature data.
[0104] The genetic environment contains many genetic parameters. Genetic parameters refer to the parameters used in improving the operation of genetic algorithms. They are set by the user and include the number of genetic iterations, the name, description, identifier, and size of the test case population. Feature parameters can be understood as the mapping of genetic parameters onto historical test case data. The feature information required by the user is extracted from historical test cases and encoded to form feature parameters (which can be characters, words, or symbols) that meet the requirements of the genetic parameters. Valid feature fields are statements or paragraphs formed by combining multiple related feature parameters. Through automatic semantic analysis of feature fields, they are identified and recombined to finally form the initial population that meets the conditions.
[0105] When generating the original test case population, the system automatically extracts genetic environment features that conform to the characteristics of historical test case data based on automatic semantic analysis. This not only enables the rapid formation of the initial test case population and the initialization of the genetic environment, greatly improving the targeting and efficiency of test data design, but also greatly expands the scope of application. It can adapt to different professional characteristics for semantic analysis, thereby improving the accuracy and adaptability of test case generation.
[0106] Specifically, the process of genetic environment, configuration parameter initialization, and formation of the initial test case population is as follows:
[0107] 1) Based on the communication protocol definitions in the software requirements specification and interface design document, configure the genetic parameter combinations. Configurable parameters specifically include seed use case ID and business scenario ID. Among them;
[0108] 2) Configure key genetic field attributes according to the target test case population attributes generated as needed, such as gene features to be ignored, manually input features and feature values, and initialize the task parameters of the genetic environment. Among these, gene features to be ignored are invalid gene fragments that the test case population does not need to retain or focus on during the intelligent test case generation process, such as the execution location, time, and personnel of the test case; input important feature attributes and feature values, including the execution steps of the test case, expected input / output, and the value range of key interface fields; after saving the key genetic field attributes, automatically initialize the variables, memory, and other resources used to construct the genetic environment and start a new task thread;
[0109] 3) After the new task thread is successfully initialized, it automatically iterates through the recorded original test cases. Based on the type of software under test, it selects the corresponding historical typical test case documents. The system analyzes and statistically analyzes effective feature information according to the requirements of test case statement structure and contextual language description standardization, extracting content including the test case name, identifier, input and output results, and execution steps, etc. It removes the genetic features that need to be ignored, retains the valuable information and adds it to the test case feature gene library, until the original test case preprocessing is completed and the initial generation of original test case population is formed.
[0110] S2. Based on the improved genetic algorithm, the initial original test case population is subjected to selective evolution processing to generate a dataset of valid test cases and a dataset of invalid and abnormal test cases; the improved genetic algorithm includes adding a mutation operator on the basis of the genetic algorithm.
[0111] S21. Based on the improved genetic algorithm, the selection operator is applied to the first-generation original test case population to obtain the first-generation high-quality test case population. Then, the crossover operator is applied to the first-generation high-quality test case population to obtain the second-generation test case population. Finally, the mutation operator is applied to the second-generation test case population to generate a valid test case dataset.
[0112] In the process of using an improved genetic algorithm for selective evolution and screening, we define a fitness function based on the coverage performance of the initial test case population on the lines of code of the software under test. Then, based on this, we calculate the fitness evaluation value, the cumulative fitness of the population, and the fitness ratio of each individual test case. We use these evaluation results as the evaluation criteria for the initial screening of individual test cases.
[0113] For each test case population, selection, crossover, and mutation operators are used for optimal selection and screening. The genetic process of the effective test case population is iteratively repeated. The selected superior test case individuals undergo a quadratic cross-product combination process to achieve natural expansion of the test case population, thus generating a batch of effective test case datasets. The specific process of generating effective test case datasets by performing optimal evolutionary processing on the initial original test case population based on the improved genetic algorithm is as follows:
[0114] 1) Filtering based on selection operators.
[0115] The fitness function is defined by evaluating the coverage performance of test cases on the incremental code of the CBB module in the software. The calculation process of selection, crossover and mutation operators in the genetic algorithm is redesigned in turn from the aspects of feature extraction, condition screening and genetic performance of seed test cases. Test cases that meet the optimal performance evaluation are selected to form a population of excellent test cases. Figure 2 This is the flowchart for selecting the operator in this embodiment. See [link / reference] Figure 2 The specific process is as follows:
[0116] Step 401: For the initial population of original test cases formed in S1 above, the unit testing tool is invoked to automatically count the number of lines of code covered by each individual test case, and to count the number of times each line of code is covered, and to calculate the fitness of the corresponding line of code. The fewer the number of times a line of code is covered, the better the test case's performance in covering that line of code, and the higher the value of the test case; conversely, a lower number of coverage times indicates a worse performance.
[0117] Step 402: Traverse all individuals in the initial original test case population, calculate the fitness evaluation value and the sum of fitness values for all individuals in the population, and calculate the individual fitness ratio value using the following formula:
[0118]
[0119] in, Fitness(gk) Indicates the fitness of an individual in a population. Fitness(sum) It is the sum of the fitness of individuals in the population. p(gk) It refers to the proportion of the fitness value of an individual in the population to the sum of the fitness values of the entire population. k represents the number of the individual in the population. For example, k = 3 represents the third individual in the population.
[0120] Step 403: Based on the distribution of individual fitness evaluation ratios, the population distribution is divided into regions according to the individual fitness ratios. The calculation formula is as follows:
[0121]
[0122] Wherein q(g k ) represents the cumulative sum of the fitness of individuals in the population; i represents the size of the population, which can be understood as the total number of individuals in the population.
[0123] The individual fitness partitions are designed as (0, q(g1)], ..., (q(g2)]. k-1 ),q(g k )], and iterate through the population to calculate the fitness values of individuals within their respective intervals.
[0124] Step 404: For each individual, a probability value between [0,1) is randomly generated. By matching the random probability value with the individual fitness partition, high-quality individuals that meet the fitness partition value range requirements are selected.
[0125] Step 405: The selected individuals are rearranged and combined according to their fitness values to form an initial population of high-quality use cases, which are then used in the further crossover operator screening module.
[0126] 2) Filtering based on crossover operators.
[0127] Figure 3 This is a flowchart of the cross-operator filtering process in this embodiment. See also... Figure 3 The specific process of crossover operator screening is as follows:
[0128] Step 501: Set the initial crossover probability as the admission condition for crossover operations on individuals in the first generation of high-quality use case population.
[0129] Based on the expected crossover probability of the initial high-quality test case population, an initial crossover probability with a value between [0.5, 1) is set as the admission condition for whether individual test cases need to undergo crossover.
[0130] Step 502: Set the number of cross-loop iterations.
[0131] To ensure that the genes of the high-quality test case population in the first generation are inherited and passed on to the next generation of individuals as much as possible, a crossover cycle number is set and evaluated. More cycles result in a richer population profile, but also significantly increase the computational load of iterations. Furthermore, this parameter is related to the number of initial samples and the complexity of the test case features; often, multiple experiments are needed to determine the optimal crossover cycle number based on specific circumstances. Local experimental data shows that after six generations of crossover iterations, the coverage of seed test cases can exceed 90%. Therefore, in this embodiment, six crossover iterations are selected.
[0132] Step 503: Determine whether cross operation is required. If the conditions for cross operation are met, proceed to step 504; otherwise, proceed to step 505.
[0133] A crossover comparison value is randomly generated between [0.5,1) and compared with the initial crossover probability. If the crossover comparison value is less than the initial crossover probability, it is considered that a crossover operation needs to occur, and step 504 is executed; otherwise, it is considered that a crossover operation does not need to occur, and step 505 is executed.
[0134] Step 504: When the crossover condition is met, set the crossover point position according to the crossover comparison value, and perform the exchange operation on the gene segments before and after the crossover point of the two parent test cases to simulate the inheritance of some gene characteristics of the parent, thereby forming a population of offspring test cases with richer gene characteristics.
[0135] Step 505: When the crossover condition is not met, directly copy the genetic data of the parent test case individual to the offspring genes to simulate the situation where the parent genetic characteristics are completely inherited.
[0136] Step 506: After the number of iterations and cross-operations is completed, the resulting second-generation test case population can be used in the mutation operator screening module.
[0137] 3) Screening based on mutation operators.
[0138] Figure 4 This is a flowchart of the mutation operator screening process according to an embodiment of the present invention. See also Figure 4 The specific process of screening mutation operators is as follows:
[0139] Step 601: Set the initial mutation probability as the admission condition for judging the mutation operation of individuals in the next generation of high-quality use case population.
[0140] Based on the expected mutation probability of the next generation of high-quality use case population, an initial mutation probability with a value between [0,1) is manually set as the admission condition for whether individual use cases need to undergo mutation operations in the later stages.
[0141] Step 602: Set the number of iterations for the mutation loop.
[0142] To ensure that the genes of the next-generation high-quality use case population reflect the diversity of individual use case data, a mutation cycle number is set and evaluated. More mutation cycles result in greater population diversity, but also significantly increase the computational load of iterations. Furthermore, this parameter is related to the number of next-generation samples and the value range of the use case feature fields, often requiring multiple experiments to determine the optimal mutation cycle number based on specific circumstances. Local experimental data shows that after 6 mutation iterations, the seed use case coverage exceeds 90%. Therefore, in this embodiment, 6 mutation iterations are selected.
[0143] Step 603: Determine whether a mutation operation is required. If the conditions for a mutation operation are met, proceed to step 604; otherwise, proceed to step 602.
[0144] A mutation comparison value is randomly generated between [0,1) and compared with the initial mutation probability. If the mutation comparison value is less than the initial mutation probability, it is considered that a mutation operation needs to be performed. Otherwise, it is considered that no mutation operation needs to be performed. Individuals that have not mutated are returned to the next generation of high-quality use case population as objects for the next iteration.
[0145] Step 604: When the mutation conditions are met, set the mutation point position according to the mutation comparison value, select the effective feature value at the corresponding mutation point position from the effective use case gene database, and perform a replacement operation on the gene value of the next generation use case population individual at the mutation point position to form the gene-mutated individual.
[0146] Step 605: After a preset number of iterations of mutation operations, a population of valid test cases is obtained.
[0147] After the iteration mutation operation is completed, the gene values at the mutation points of the mutated individuals are classified and expanded according to the equivalence class partitioning method within their valid value range, forming a population of effective test cases with diverse individual characteristics.
[0148] S22. Perform mutation operation on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases.
[0149] A mutation gene library is automatically identified and constructed based on the data protocol format. This library serves as the data source for mutation operators. The mutation gene library includes invalid boundary genes (including those on and outside invalid boundaries), anomalous genes (including anomalous frame headers, anomalous frame lengths, and anomalous frame tails), and garbled character genes (i.e., non-numeric genes, including characters, letters, and symbols). For individual use cases within the established valid use case population, invalid or anomalous genes are extracted from the mutation gene library and replaced with those genes at the mutation point locations, forming an invalid / anomalous use case population.
[0150] Figure 5 This is a flowchart of the mutation operator screening process. See also... Figure 5 The mutation operator screening process is as follows:
[0151] Step 701: According to the data protocol format, the system automatically identifies the value range of each important gene fragment, parses and saves information such as the boundaries and length of each field. At the same time, the operator selects the gene fragments to be mutated according to the usage requirements. If no selection is made, the system will mutate all gene fragments with value ranges by default.
[0152] Step 702: The system constructs a mutation gene library according to the value range of gene fragments and mutation types, including invalid boundary mutations, abnormal frame format mutations, and garbled character mutations. Invalid boundary mutations include those on and outside invalid boundaries, and their boundary genes are set as mutation points. Abnormal frame format mutations include abnormal frame headers, abnormal frame lengths, abnormal frame tails, etc., and their abnormal data bits are set as mutation points. Garbled character mutations include various non-numeric gene values, such as characters, letters, punctuation marks, etc., and their important gene fragment positions are set as mutation points.
[0153] Step 703: To ensure the scale and coverage of invalid and abnormal test cases, the number of mutation iterations needs to be manually set. More mutation iterations result in more invalid and abnormal test cases and better coverage, but also significantly increase the computational load of iterations. Often, multiple experiments are needed to determine the optimal number of mutation iterations based on the actual situation. Local experimental data shows that when the mutation gene library has a sufficiently rich data type, approximately 3 iterations are sufficient to achieve over 90% coverage. Therefore, in this embodiment, the number of mutation iterations is also set to 3.
[0154] Step 704: According to the mutation type, select the corresponding mutation gene value from the mutation gene library and replace it with the gene value of the gene fragment to be mutated at each mutation point position to form an individual after gene mutation.
[0155] Step 705: After the number of iterations of mutation operation is completed, the resulting mutant individuals are arranged and combined according to mutation type to finally form a population of invalid / abnormal test cases of a certain size.
[0156] The valid, invalid, and abnormal test cases generated in batches above can be used for subsequent software testing.
[0157] This completes the entire process of the intelligent generation method for software test cases based on an improved genetic algorithm in this embodiment.
[0158] Example 2:
[0159] Secondly, the present invention also provides a software test case intelligent generation system based on an improved genetic algorithm, the system comprising:
[0160] The initial raw test case population acquisition module is used to acquire the initial raw test case population.
[0161] The test case generation module is used to perform optimal evolutionary processing on the initial original test case population based on an improved genetic algorithm to generate a dataset of valid test cases and a dataset of invalid and abnormal test cases; the improved genetic algorithm includes adding a mutation operator on the basis of the genetic algorithm.
[0162] Optionally, the initial original test case population acquisition module acquires the initial original test case population by including:
[0163] The genetic environment and genetic parameters are initialized, and based on the automatic semantic analysis method, effective feature fields with genetic environment characteristics that conform to the characteristics of historical test case data are extracted from the historical test case data according to software requirements and interface protocols. Then, the gene sequence of the effective feature fields is constructed by encoding, and the initial generation of original test case population is completed.
[0164] Optionally, the test case generation module performs optimal evolutionary processing on the initial original test case population based on an improved genetic algorithm to generate a valid test case dataset and an invalid and abnormal test case dataset, including:
[0165] S21. Based on the improved genetic algorithm, the selection operator is performed on the first generation of original test case population to obtain the first generation of high-quality test case population. Then, the crossover operator is performed on the first generation of high-quality test case population to obtain the second generation of test case population. Finally, the mutation operator is performed on the second generation of test case population to generate a valid test case dataset.
[0166] S22. Perform mutation operation on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases.
[0167] Optionally, step S21, which involves performing selection operator processing on the initial generation of original test case population based on an improved genetic algorithm to obtain an initial generation of high-quality test case population, then performing crossover operator processing on the initial generation of high-quality test case population to obtain a second generation of test case population, and finally performing mutation operator processing on the second generation of test case population to generate a valid test case dataset, includes:
[0168] The initial high-quality use case population obtained by performing selection operator processing on the initial original use case population includes:
[0169] Step 401: Count the number of lines of code covered by each test case in the initial original test case population, the number of times each line of code is covered, and calculate the fitness of the corresponding line of code based on this information.
[0170] Step 402: Traverse all individuals in the initial original use case population, calculate the fitness evaluation value and the cumulative fitness of all individuals in the population, and then calculate the individual fitness ratio value based on the fitness evaluation value and the cumulative fitness.
[0171] Step 403: Based on the distribution of individual fitness ratios, divide the population distribution into regions according to the individual fitness ratios, and calculate the fitness value intervals of each individual in the population.
[0172] Step 404: Randomly generate a probability value between [0,1) for each individual. By matching the random probability value with the individual fitness partition, select high-quality individuals that meet the fitness partition value range requirements.
[0173] Step 405: The selected individuals are rearranged and combined according to their fitness values to form the initial high-quality use case population.
[0174] The second-generation test case population is obtained by performing crossover operation on the first-generation high-quality test case population, including:
[0175] Step 501: Set the initial crossover probability as the admission condition for crossover operation of individuals in the first generation of high-quality use case population;
[0176] Step 502: Set the number of cross-loop iterations;
[0177] Step 503: Determine whether a crossover operation is required based on the initial crossover probability. If the conditions for a crossover operation to occur are met, proceed to step 504; otherwise, proceed to step 505.
[0178] Step 504: When the crossover condition is met, set the crossover point position according to the crossover comparison value, and perform the exchange operation on the gene segments before and after the crossover point of the two parent test cases to form the offspring test case population.
[0179] Step 505: When the crossover condition is not met, directly copy the genetic data of the parent test case individual to the offspring genes as is.
[0180] Step 506: After the number of cross-loop iterations is completed, a second-generation use case population is formed;
[0181] Performing mutation operator processing on the next-generation test case population to generate a valid test case dataset includes:
[0182] Step 601: Set the initial mutation probability as the admission condition for judging the mutation operation of individuals in the next generation of high-quality test cases.
[0183] Step 602: Set the number of iterations for the mutation loop;
[0184] Step 603: Determine whether a mutation operation is needed based on the initial mutation probability. If the condition for a mutation operation to occur is met, proceed to step 604; otherwise, proceed to step 602.
[0185] Step 604: When the mutation condition is met, set the mutation point position according to the mutation comparison value, select the effective feature value at the corresponding mutation point position from the effective use case gene database, and perform a replacement operation on the gene value of the next generation use case population individual at the mutation point position to form the gene-mutated individual.
[0186] Step 605: After iterating the mutation loop a certain number of times, a population of valid test cases is obtained.
[0187] Optionally, step S22, performing mutation operations on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases, includes:
[0188] Step 701: Identify the gene fragments that need to be mutated;
[0189] Step 702: Based on the value range of the gene fragment, construct a mutant gene library according to the mutation type; the mutation type includes data types such as invalid boundary mutation, abnormal frame format mutation, and garbled code mutation;
[0190] Step 703: Set the number of mutation cycles;
[0191] Step 704: According to the mutation type, select the corresponding mutation gene value from the mutation gene library and replace it with the gene value of the gene fragment to be mutated at each mutation point to form an individual after gene mutation;
[0192] Step 705: After the number of iterations of the mutation cycle is completed, the individual mutations formed are arranged and combined according to the mutation type to form a set of invalid and abnormal test cases.
[0193] It is understood that the intelligent software test case generation system based on the improved genetic algorithm provided in this embodiment of the invention corresponds to the intelligent software test case generation method based on the improved genetic algorithm described above. The explanations, examples, and beneficial effects of the relevant content can be referred to the corresponding content in the intelligent software test case generation method based on the improved genetic algorithm, and will not be repeated here.
[0194] In summary, compared with existing technologies, it has the following beneficial effects:
[0195] 1. This invention first obtains an initial population of original test cases. Then, based on an improved genetic algorithm, it progressively selects, crossovers, and performs mutation operations on the initial population to generate a dataset of valid test cases. Next, it performs mutation operations on the valid test case dataset to generate a set of invalid and anomalous test cases. This invention's batch intelligent generation of valid, invalid, and anomalous test cases solves the problems of existing software test case design and generation heavily relying on manual labor, insufficient test case generation efficiency, mismatch between the volume of test cases and the growth rate of software code size, and low test case accuracy. It improves the intelligence level and efficiency of software test case generation.
[0196] 2. This invention extracts effective feature fields from historical test case data based on automatic semantic analysis, and constructs a gene database of feature parameters in accordance with the protocol format encoding, so as to realize the rapid formation of the initial original test case population and the initialization of the genetic environment, which greatly improves the pertinence and efficiency of test data design.
[0197] 3. This invention is based on fitness evaluation of incremental code coverage. It utilizes improved genetic algorithms for selection, crossover, and mutation to perform optimal screening and calculation, and generates a batch of valid test case datasets. This effectively improves the accuracy of the evaluation test case data and enables precise screening of high-performing test case data during the genetic process.
[0198] 4. Based on the principle of gene mutation, this invention constructs a mutation model for the effective test case population, simulates the invalid and abnormal ways of gene mutation, and thus completes the supplementation of effective test cases, which together form the core test case data cultivation process, improving the intelligence level and accuracy of test case generation.
[0199] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0200] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for intelligent generation of software test cases based on an improved genetic algorithm, characterized in that, The method includes: Obtain the initial population of original test cases; The original test case population is subjected to selective evolutionary processing based on an improved genetic algorithm to generate a dataset of valid test cases and a dataset of invalid and abnormal test cases; the improved genetic algorithm includes adding a mutation operator to the genetic algorithm. The initial population of original use cases obtained includes: Genetic environment and genetic parameters are initialized, and based on automatic semantic analysis, effective feature fields with genetic environment characteristics that conform to the characteristics of historical test case data are extracted from historical test case data according to software requirements and interface protocols. Then, gene sequences of the effective feature fields are constructed by encoding, and the initial generation of original test case population is constructed. The step of generating a valid test case dataset and an invalid and abnormal test case dataset by performing a merit-based evolutionary process on the initial original test case population using an improved genetic algorithm includes: S21. Based on the improved genetic algorithm, the selection operator is performed on the first generation of original test case population to obtain the first generation of high-quality test case population. Then, the crossover operator is performed on the first generation of high-quality test case population to obtain the second generation of test case population. Finally, the mutation operator is performed on the second generation of test case population to generate a valid test case dataset. S22. Perform mutation operations on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases; Step S21 involves performing selection operator processing on the initial generation of original test case population based on an improved genetic algorithm to obtain an initial generation of high-quality test case population, then performing crossover operator processing on the initial generation of high-quality test case population to obtain a second generation of test case population, and finally performing mutation operator processing on the second generation of test case population to generate a valid test case dataset, including: The initial high-quality use case population obtained by performing selection operator processing on the initial original use case population includes: Step 401: Count the number of lines of code covered by each test case in the initial original test case population, the number of times each line of code is covered, and calculate the fitness of the corresponding line of code based on this information. Step 402: Traverse all individuals in the initial original use case population, calculate the fitness evaluation value and the cumulative fitness of all individuals in the population, and then calculate the individual fitness ratio value based on the fitness evaluation value and the cumulative fitness. Step 403: Based on the distribution of individual fitness ratios, divide the population distribution into regions according to the individual fitness ratios, and calculate the fitness value intervals of each individual in the population. Step 404: Randomly generate a probability value between [0,1) for each individual. By matching the random probability value with the individual fitness partition, select high-quality individuals that meet the fitness partition value range requirements. Step 405: The selected individuals are rearranged and combined according to their fitness values to form the initial high-quality use case population. The second-generation test case population is obtained by performing crossover operation on the first-generation high-quality test case population, including: Step 501: Set the initial crossover probability as the admission condition for crossover operation of individuals in the first generation of high-quality use case population; Step 502: Set the number of cross-loop iterations; Step 503: Determine whether a crossover operation is required based on the initial crossover probability. If the conditions for a crossover operation to occur are met, proceed to step 504; otherwise, proceed to step 505. Step 504: When the crossover condition is met, set the crossover point position according to the crossover comparison value, and perform the exchange operation on the gene segments before and after the crossover point of the two parent test cases to form the offspring test case population. Step 505: When the crossover condition is not met, directly copy the genetic data of the parent test case individual to the offspring genetic data as is. Step 506: After the number of cross-loop iterations is completed, a second-generation use case population is formed; Performing mutation operator processing on the next-generation test case population to generate a valid test case dataset includes: Step 601: Set the initial mutation probability as the admission condition for judging the mutation operation of individuals in the next generation of high-quality use case population. Step 602: Set the number of iterations for the mutation loop; Step 603: Determine whether a mutation operation is needed based on the initial mutation probability. If the condition for a mutation operation to occur is met, proceed to step 604; otherwise, proceed to step 602. Step 604: When the mutation condition is met, set the mutation point position according to the mutation comparison value, select the effective feature value at the corresponding mutation point position from the effective use case gene database, and perform a replacement operation on the gene value of the next generation use case population individual at the mutation point position to form the gene-mutated individual. Step 605: After iterating the mutation loop a certain number of times, a population of valid test cases is obtained; S22, performing mutation operations on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases, includes: Step 701: Identify the gene fragments that need to be mutated; Step 702: Based on the value range of the gene fragment, construct a mutant gene library according to the mutation type; the mutation type includes data types such as invalid boundary mutation, abnormal frame format mutation, and garbled code mutation; Step 703: Set the number of mutation cycles; Step 704: According to the mutation type, select the corresponding mutation gene value from the mutation gene library and replace it with the gene value of the gene fragment to be mutated at each mutation point to form an individual after gene mutation; Step 705: After the number of iterations of the mutation cycle is completed, the individual mutations formed are arranged and combined according to the mutation type to form a set of invalid and abnormal test cases.
2. A software test case intelligent generation system based on an improved genetic algorithm, characterized in that, The system includes: The initial raw test case population acquisition module is used to acquire the initial raw test case population. The test case generation module is used to perform optimal evolutionary processing on the initial original test case population based on an improved genetic algorithm to generate a valid test case dataset and an invalid and abnormal test case dataset; the improved genetic algorithm includes adding a mutation operator to the genetic algorithm. The initial raw test case population acquisition module acquires the initial raw test case population including: Genetic environment and genetic parameters are initialized, and based on automatic semantic analysis, effective feature fields with genetic environment characteristics that conform to the characteristics of historical test case data are extracted from historical test case data according to software requirements and interface protocols. Then, gene sequences of the effective feature fields are constructed by encoding, and the initial generation of original test case population is constructed. The test case generation module uses an improved genetic algorithm to perform optimal evolutionary processing on the initial original test case population to generate a valid test case dataset and an invalid and abnormal test case dataset, including: S21. Based on the improved genetic algorithm, the selection operator is performed on the first generation of original test case population to obtain the first generation of high-quality test case population. Then, the crossover operator is performed on the first generation of high-quality test case population to obtain the second generation of test case population. Finally, the mutation operator is performed on the second generation of test case population to generate a valid test case dataset. S22. Perform mutation operations on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases; Step S21 involves performing selection operator processing on the initial generation of original test case population based on an improved genetic algorithm to obtain an initial generation of high-quality test case population, then performing crossover operator processing on the initial generation of high-quality test case population to obtain a second generation of test case population, and finally performing mutation operator processing on the second generation of test case population to generate a valid test case dataset, including: The initial high-quality use case population obtained by performing selection operator processing on the initial original use case population includes: Step 401: Count the number of lines of code covered by each test case in the initial original test case population, the number of times each line of code is covered, and calculate the fitness of the corresponding line of code based on this information. Step 402: Traverse all individuals in the initial original use case population, calculate the fitness evaluation value and the cumulative fitness of all individuals in the population, and then calculate the individual fitness ratio value based on the fitness evaluation value and the cumulative fitness. Step 403: Based on the distribution of individual fitness ratios, divide the population distribution into regions according to the individual fitness ratios, and calculate the fitness value intervals of each individual in the population. Step 404: Randomly generate a probability value between [0,1) for each individual. By matching the random probability value with the individual fitness partition, select high-quality individuals that meet the fitness partition value range requirements. Step 405: The selected individuals are rearranged and combined according to their fitness values to form the initial high-quality use case population. The second-generation test case population is obtained by performing crossover operation on the first-generation high-quality test case population, including: Step 501: Set the initial crossover probability as the admission condition for crossover operation of individuals in the first generation of high-quality use case population; Step 502: Set the number of cross-loop iterations; Step 503: Determine whether a crossover operation is required based on the initial crossover probability. If the conditions for a crossover operation to occur are met, proceed to step 504; otherwise, proceed to step 505. Step 504: When the crossover condition is met, set the crossover point position according to the crossover comparison value, and perform the exchange operation on the gene segments before and after the crossover point of the two parent test cases to form the offspring test case population. Step 505: When the crossover condition is not met, directly copy the genetic data of the parent test case individual to the offspring genetic data as is. Step 506: After the number of cross-loop iterations is completed, a second-generation use case population is formed; Performing mutation operator processing on the next-generation test case population to generate a valid test case dataset includes: Step 601: Set the initial mutation probability as the admission condition for judging the mutation operation of individuals in the next generation of high-quality use case population. Step 602: Set the number of iterations for the mutation loop; Step 603: Determine whether a mutation operation is needed based on the initial mutation probability. If the condition for a mutation operation to occur is met, proceed to step 604; otherwise, proceed to step 602. Step 604: When the mutation condition is met, set the mutation point position according to the mutation comparison value, select the effective feature value at the corresponding mutation point position from the effective use case gene database, and perform a replacement operation on the gene value of the next generation use case population individual at the mutation point position to form the gene-mutated individual. Step 605: After iterating the mutation loop a certain number of times, a population of valid test cases is obtained; S22, performing mutation operations on individual test cases in the valid test case population to obtain a set of invalid and abnormal test cases, includes: Step 701: Identify the gene fragments that need to be mutated; Step 702: Based on the value range of the gene fragment, construct a mutant gene library according to the mutation type; the mutation type includes data types such as invalid boundary mutation, abnormal frame format mutation, and garbled code mutation; Step 703: Set the number of mutation cycles; Step 704: According to the mutation type, select the corresponding mutation gene value from the mutation gene library and replace it with the gene value of the gene fragment to be mutated at each mutation point to form an individual after gene mutation; Step 705: After the number of iterations of the mutation cycle is completed, the individual mutations formed are arranged and combined according to the mutation type to form a set of invalid and abnormal test cases.
Citation Information
Patent Citations
Chaos genetic algorithm based test case intensive simple algorithm
CN104268077A
