Test case generation method, device, equipment, storage medium and program product

By automatically extracting test elements and using genetic algorithms to optimize test cases, the problems of low coverage and low efficiency of manually written test cases are solved, achieving efficient and dynamic test case generation and defect discovery.

CN123157604APending Publication Date: 2026-11-24INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611524512.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-29
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

In existing technologies, manually writing test cases is limited by the tester's personal experience, which can easily lead to the omission of boundary conditions, abnormal scenarios and complex combination paths, resulting in low test coverage, high risk of missing defects, low efficiency, inability to quickly respond to changes in software requirements, and limited defect detection capabilities of the generated test cases.

Method used

By automatically extracting test elements from the original test requirements information of the target software, initial test cases are generated. Then, a genetic algorithm is used to perform multiple rounds of iterative evolution operations. Based on test feedback data, the test cases are optimized, including selection, crossover, and mutation operations, to generate optimized test cases with the highest fitness scores.

Benefits of technology

It significantly improved test coverage, reduced the risk of missed defects, increased test case generation efficiency, enhanced defect discovery capabilities, reduced errors caused by manual modifications, and enabled dynamic optimization of the test case set.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123157604A_ABST
    Figure CN123157604A_ABST
Patent Text Reader

Abstract

This application provides a test case generation method, apparatus, device, storage medium, and program product, relating to the fintech field or other related fields. The method includes: generating multiple initial test cases based on target test elements extracted from the original test requirements information of the target software, using these as an initial population; performing multiple iterations of evolutionary operations on the initial population, the evolutionary operations including: determining the fitness score of each individual based on the test feedback data of each test case in the current iteration; performing a selection mutation operation using a genetic algorithm on the current iteration population based on the fitness scores of each individual to generate the population for the next iteration; and, after satisfying a preset termination condition, selecting the individuals with the highest corresponding fitness scores in the final iteration population as optimized test cases. The method of this application can automatically generate optimized test cases.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of financial technology or other related fields, and in particular to a test case generation method, apparatus, device, storage medium and program product. Background Technology

[0002] In the software development process, software testing is a crucial step in ensuring software quality, and test cases are the basic execution units of software testing, typically containing information such as test steps, input data, and expected results. During test execution, testers operate the target software according to the test cases and compare the actual output with the expected results to determine whether the software has defects. High-quality test cases should effectively cover normal functional paths, boundary conditions, and various abnormal scenarios, thereby exposing potential defects in the software to the greatest extent possible.

[0003] In existing technologies, test case generation mainly relies on the manual experience of testers. Specifically, testers first read and understand the business requirements document or software specification, and then manually write each test case based on their understanding of the business logic and testing methodologies (such as equivalence partitioning, boundary value analysis, cause-effect graphing, etc.).

[0004] The aforementioned existing technologies have the following problems in practical applications: 1. Manually writing test cases is limited by the testers' personal experience and subjective judgment, which can easily lead to the omission of boundary conditions, abnormal scenarios, and complex business combination paths, resulting in insufficient test coverage and a high risk of missed defects; 2. When software requirements change, a large number of related test cases need to be manually checked and modified one by one, resulting in a huge maintenance workload and the potential introduction of new errors; 3. The speed of manually designing test cases is far lower than the iteration rhythm of software development, and frequent requirement changes cause the efficiency of test case generation to restrict the speed of software delivery; 4. The test case sets generated by existing technologies are static and cannot be optimized based on the actual execution effect of the test cases, which may result in a limited ability to discover software defects. Summary of the Invention

[0005] This application provides a test case generation method, apparatus, device, storage medium, and program product to solve the following technical problems caused by manually writing test cases in the prior art: manual writing is limited by subjective experience, and it is easy to miss boundary conditions, abnormal scenarios, and complex combination paths, resulting in low test coverage, high risk of missing defects, and low efficiency. When a large number of test cases need to be modified, the workload is huge and new errors are easily introduced; the defect detection capability of manually written static test cases is limited.

[0006] Firstly, this application provides a test case generation method, the method comprising:

[0007] Extract target test elements from the original test requirements information of the target software;

[0008] Based on the target test elements, multiple initial test cases for the target software are generated;

[0009] Using the initial test cases as an initial population, perform multiple iterations of evolutionary operations on the initial population, the evolutionary operations including:

[0010] Based on the test feedback data obtained after each test case, as an individual, is executed on the target software in the population of the current iteration round, the fitness score of each individual is determined, and the fitness score is used to indicate the corresponding individual's defect discovery capability in the target software.

[0011] Based on the fitness scores of each individual, the selection, crossover, and mutation operations of the genetic algorithm are performed on the population in the current iteration round to generate the population for the next iteration round.

[0012] After the preset termination condition is met, the individuals with the highest fitness scores in the population during the final iteration round will be selected as optimized test cases.

[0013] Secondly, this application provides a test case generation apparatus, the apparatus comprising:

[0014] The extraction module is used to extract target test elements from the original test requirement information of the target software.

[0015] A generation module is used to generate multiple initial test cases for the target software based on the target test elements.

[0016] An optimization module is configured to perform an evolutionary operation for multiple iterations on the initial population, using the plurality of initial test cases as an initial population, wherein the evolutionary operation includes:

[0017] Based on the test feedback data obtained after each test case, as an individual, is executed on the target software in the population of the current iteration round, the fitness score of each individual is determined, and the fitness score is used to indicate the corresponding individual's defect discovery capability in the target software.

[0018] Based on the fitness scores of each individual, the selection, crossover, and mutation operations of the genetic algorithm are performed on the population in the current iteration round to generate the population for the next iteration round.

[0019] After the preset termination condition is met, the individuals with the highest fitness scores in the population during the final iteration round will be selected as optimized test cases.

[0020] Thirdly, this application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0021] The memory stores computer-executed instructions;

[0022] The processor executes computer execution instructions stored in the memory to implement the method as described in the first aspect.

[0023] Fourthly, this application provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the method described in the first aspect.

[0024] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.

[0025] The test case generation method, apparatus, equipment, storage medium, and program product provided in this application have the following technical effects:

[0026] 1. By automatically extracting target test elements from the original test requirements information of the target software and generating multiple initial test cases in batches, compared to manually writing test cases, this method can systematically cover various test scenarios derived from the target test elements. This reduces omissions of boundary conditions, abnormal scenarios, and complex combination paths due to limitations in human subjective experience, effectively improving test coverage and reducing the risk of missed defects. Furthermore, this method of batch generating multiple initial test cases significantly improves the efficiency of initial test case production. When a large number of test cases need to be optimized subsequently, the automated evolutionary operation replaces manual modification, overcoming the problems of large workload and the potential for introducing new errors through manual modification.

[0027] 2. This method uses multiple initial test cases as an initial population and performs multiple iterations of evolutionary operations on the initial population. These evolutionary operations include: determining a fitness score (indicating defect detection capability) based on the test feedback data obtained after each test case is executed on the target software; and performing selection, crossover, and mutation operations using a genetic algorithm based on the fitness scores to generate the next round of the population. Finally, the individuals with the highest fitness scores are selected as optimized test cases. This approach constructs an optimized path of "execution-feedback-evolution" for test cases, overcoming the limited defect detection capability of manually written static test cases. Specifically, based on the characteristics of genetic algorithms, the fitness score quantifies the ability of each test case to actually expose defects in the target software; selection operations ensure that test cases with strong defect detection capabilities are retained; and crossover and mutation operations recombine test elements among cases to generate new case variants, exploring test path combinations that are difficult to exhaustively enumerate manually. Through multiple iterations, the population is continuously evolved, resulting in a set of optimized test cases consisting of individuals with the highest fitness scores. This leads to an optimized test case set with a defect detection capability far exceeding that of traditional manually written static test cases. Attached Figure Description

[0028] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0029] Figure 1 This is a schematic diagram of the test case generation method provided in the embodiments of this application;

[0030] Figure 2 A flowchart illustrating the method for calculating fitness scores provided in this application embodiment. Figure 1 ;

[0031] Figure 3 A flowchart illustrating the method for calculating fitness scores provided in this application embodiment. Figure 2 ;

[0032] Figure 4 A schematic flowchart of a method for calculating the final fitness score provided in an embodiment of this application;

[0033] Figure 5 This is a schematic diagram of the process for extracting target test elements provided in an embodiment of this application;

[0034] Figure 6 A schematic diagram of the test case generation device provided in the embodiments of this application;

[0035] Figure 7 This is a schematic diagram of the electronic device structure provided in an embodiment of this application.

[0036] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation

[0037] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.

[0038] It should be noted that the test case generation method, apparatus, equipment, storage medium and program product provided in this application can be used in the field of financial technology, or in any field other than financial technology. The application field of the test case generation method, apparatus, equipment, storage medium and program product in this application is not limited.

[0039] To address the following technical problems caused by manually writing test cases in existing technologies: manual writing is limited by subjective experience, easily overlooking boundary conditions, abnormal scenarios, and complex combination paths, resulting in low test coverage, high risk of missed defects, and low efficiency, with a huge workload and potential for introducing new errors when modifying a large number of test cases; manually written static test cases have limited defect detection capabilities. The technical concept of this application is:

[0040] First, key test elements are automatically extracted from the original test requirements of the target software, and a set of initial test cases is generated in batches based on these elements. Then, these initial test cases are treated as a biological population, and the defect-finding capability demonstrated by each test case after execution on the target software is used as its fitness score. Through selection, crossover, and mutation operations in a genetic algorithm, the test case set is iteratively evolved across multiple generations, ultimately selecting the few test cases with the highest fitness as optimized test cases. The core of this scheme lies in treating the generation and optimization of test cases as a quantifiable evolutionary process, using post-execution feedback data to drive the self-improvement of the test case set, thereby automatically obtaining test cases with higher defect-finding efficiency.

[0041] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.

[0042] This embodiment provides a test case generation method, which can be executed by a test case generation system (hereinafter referred to as the system) running on a computer device. The following describes each step of the method in detail with reference to the accompanying drawings and specific scenarios.

[0043] Figure 1 This is a schematic diagram of the test case generation method provided in the embodiments of this application, such as... Figure 1 As shown, the method includes:

[0044] S101. Extract target test elements from the original test requirements information of the target software;

[0045] In this step, the system first obtains the original test requirements information of the target software. In this embodiment, the original test requirements information can be in the form of a natural language document, such as a requirements specification, a function list, etc.

[0046] In practice, the system can execute the following parsing sub-steps:

[0047] First, the system receives the original test requirements information through a standardized interface. This standardized interface can be designed to support common document formats, such as Word documents or plain text files, and automatically identify their encoding methods.

[0048] Next, the system calls the syntax parser to perform structured analysis on the document. Specifically, the syntax parser identifies elements such as chapter titles, paragraphs, and list items in the document based on a predefined document structure template. For example, if the document contains fixed titles such as "Project Introduction", "Requirements", or "List of Main Functions", the syntax parser automatically locates these areas and extracts their content.

[0049] Then, the system invokes a semantic analyzer to perform deep understanding of the extracted text fragments. This semantic analyzer can have a built-in domain dictionary and dependency parsing model, enabling it to identify key entities and their relationships within the text. For example, for the description "After the user enters their mobile phone number and clicks to get a verification code, the system should send an SMS verification code to that mobile phone number," the semantic analyzer can extract:

[0050] Prerequisite: The user enters their mobile phone number and clicks to get the verification code;

[0051] Target of operation: System;

[0052] Expected action: Send a verification code via SMS to this mobile number.

[0053] It should be noted that the extracted information in this embodiment is the target test element, including but not limited to: preconditions, input data, operation steps, expected results, abnormal scenarios, etc.

[0054] The system can then perform logical integrity verification on the extracted target test elements. In this embodiment, the verification rules may include, for example:

[0055] Check whether each step of the operation has the corresponding expected result;

[0056] Check if the input data is within a reasonable range;

[0057] Check for contradictory condition descriptions. For example, it might require both "user is logged in" and "user is not logged in".

[0058] If a missing or conflict is found, the system can generate an anomaly report, marking the specific location and type of the problem, for manual review or automatic correction.

[0059] Through the above processing, the system transforms unstructured raw requirement information into a structured set of target test elements, and stores it in memory or a database in the form of a domain-specific model. This model can organize data in the form of key-value pairs or nested objects, which facilitates efficient access in subsequent steps.

[0060] S102. Based on the target test elements, generate multiple initial test cases for the target software;

[0061] In this step, the system calls the test case generation engine to receive structured target test elements from S101 and automatically generates a batch of initial test cases based on the built-in rule base.

[0062] In this step, based on the target test elements, multiple initial test cases for the target software are generated, including:

[0063] Determine the parameter value boundaries and equivalence classes of the target parameters in the target test elements;

[0064] Invoke the preset rules to generate multiple first test parameter values ​​for the target parameter based on the parameter value boundaries, and generate second test parameter values ​​for the equivalence class;

[0065] Initial test cases are generated based on the target test elements, the first test parameter value, and the second test parameter value.

[0066] Specifically, the test case generation engine scans all parameter information in the target test elements. For each parameter, the engine identifies its data type (such as integer, floating-point number, string, enumeration, etc.) and constraints (such as value range, length limit, list of optional values, etc.). If the parameter is numeric and has a defined value range (e.g., an age field requires 1-150), the test case generation engine can automatically identify the parameter value boundaries: the lower boundary is 1, and the upper boundary is 150. The test case generation engine can also identify implicit boundaries based on business logic; for example, "greater than 0" means boundary values ​​of 0 and 1; "not exceeding 100" means boundary values ​​of 100 and 101.

[0067] Meanwhile, the test case generation engine can divide the input domain into several equivalence classes based on the type and constraints of the target parameters. Taking age as an example, valid equivalence classes include integers between 1 and 150; invalid equivalence classes include integers less than 1, integers greater than 150, non-numeric characters, and null values. For string type parameters (such as usernames with a length of 1-20 characters), valid equivalence classes are strings with a length of 1-20, and invalid equivalence classes are empty strings, strings exceeding 20 characters, and strings containing special characters. The test case generation engine stores all equivalence classes in categories.

[0068] Next, the test case generation engine calls the built-in rule library to generate initial test cases based on the generation rules for boundary values ​​and equivalence classes. The specific implementation process is as follows:

[0069] Generating the first test parameter values ​​(boundary values): The rule base uses boundary value analysis to generate multiple test values ​​for each boundary point. In one possible implementation, typical rules include: for the lower boundary L, generating L, L+1, and L-1 (if L-1 is valid); for the upper boundary U, generating U, U-1, and U+1 (if U+1 is valid). For example, if the age parameter boundaries are 1 and 150, the generated first test parameter values ​​include: 0, 1, 2, 149, 150, and 151. If the parameter is an enumeration type (such as gender values ​​"male" and "female"), the boundary values ​​degenerate into the enumeration values ​​themselves.

[0070] Generating the second test parameter value (equivalence class): The rule base uses equivalence class partitioning, selecting a representative value from each equivalence class. For valid equivalence classes, a median or typical value is usually selected; for invalid equivalence classes, a value that clearly violates the constraint is selected. For example, for age, the valid equivalence class is 75, and invalid equivalence classes are -5 (less than 1), 200 (greater than 150), abc (not a number), and an empty string. For Boolean parameters, two values, true and false, are directly generated.

[0071] Then, the test case generation engine combines the various parameter values ​​generated in the previous steps with other information (such as preconditions, operation steps, and expected result templates) extracted from the target test elements in S101 to generate complete test cases. The combination strategy can employ, for example, Cartesian product or orthogonal experimental design to avoid an excessive number of cases. Specifically, for each parameter, the test case generation engine selects a value from the first and second test parameter value lists and substitutes it into the test step. For example, if the test step is "Enter age: [age]", then the selected specific value replaces the [age] placeholder.

[0072] The test case generation engine also needs to consider the dependencies between parameters. For example, if the precondition requires "the user has registered", then the age parameter must be a valid value; if the precondition is "the user has not registered", then the age parameter can be an invalid value.

[0073] Ultimately, each generated test case contains complete fields: case number, requirement identifier, preconditions, test steps (including specific parameter values), expected result (dynamically generated based on parameter values, such as "system prompts 'age is invalid'" or "system displays registration successful"), priority, etc. The test cases generated in this step are the initial test cases.

[0074] In addition, the rule base can also contain template rules for common business scenarios, such as login, payment, and query scenarios. The engine will automatically match the corresponding template based on the business type identified in the target test elements and fill in the specific parameter values, thereby quickly generating a set of standardized test cases.

[0075] The above method for generating initial test cases has the following technical effects:

[0076] The method described above automatically identifies the boundary values ​​and equivalence classes of the target parameters and generates corresponding test parameter values ​​according to preset rules. This ensures that the generated initial test cases systematically cover boundary conditions and various equivalence classes, avoiding omissions caused by subjective experience during manual testing. Especially for complex business systems with a large number of parameters, this method ensures that the boundaries and equivalence classes of each parameter are fully tested, thereby improving the comprehensiveness of the tests. Furthermore, this method automatically generates test parameter values ​​for all boundary values ​​and equivalence classes at once through a rule base and automatically combines them into complete test cases. Compared to manual testing, this significantly improves test case generation efficiency and avoids errors that may occur during manual testing.

[0077] To ensure the quality of the initial test cases, the engine can further perform a round of basic syntax checks and logical verifications. For example, it checks for circular references in the test steps or whether the expected result contradicts the preconditions. Clearly non-compliant cases are marked as invalid and removed from the initial test case set.

[0078] Finally, the engine outputs a set containing multiple initial test cases, which serves as the starting point for subsequent iterative optimizations.

[0079] S103. Using multiple initial test cases as the initial population, perform multiple iterations of evolutionary operations on the initial population. The evolutionary operations include: determining the fitness score of each individual based on the test feedback data obtained after each test case in the current iteration population is executed on the target software. The fitness score is used to indicate the corresponding individual's ability to discover defects in the target software; based on the fitness scores of each individual, perform selection, crossover, and mutation operations of a genetic algorithm on the current iteration population to generate the population for the next iteration.

[0080] In this step, a genetic algorithm is introduced to iteratively optimize the initial test case set. The specific implementation method is as follows:

[0081] First, the multiple initial test cases generated by S102 are considered as an initial population, where each test case is an individual. Each individual carries a set of genes that encode the key attributes (test elements) of that test case, such as the values ​​of input parameters, the order of operation steps, and the type of expected result. The gene encoding method can be binary string, real number vector, or symbolic encoding. In practical applications, the gene encoding method can specifically depend on the type of test case.

[0082] Next, the system performs multiple iterations of evolutionary operations, each of which includes the following sub-steps:

[0083] Sub-step 1: Evaluate fitness score:

[0084] In the current iteration, the system executes each individual in the population (i.e., each test case) sequentially on the target software. Execution can be either by actually running the target software and simulating user operations, or by calling the target software's interface for automated testing. After execution, the system collects test feedback data for each test case, including: whether the case triggered a software defect (i.e., the actual result does not match the expected result), and the severity of the triggered defect.

[0085] Based on this feedback data, the system calculates the fitness score for each individual. Figure 2 A flowchart illustrating the method for calculating fitness scores provided in this application embodiment. Figure 1,like Figure 2 As shown, optionally, based on the test feedback data obtained after each test case in the current iteration of the population is executed on the target software, the fitness score of each individual is determined, including:

[0086] S201. In the test feedback data, the number of defects detected and the defect level score of each entity after execution in the target software are obtained. The defect level score is positively correlated with the severity of the detected defects.

[0087] Specifically, for each individual test case, the system first counts the total number of defects detected during the execution of that test case (the number of detected defects). Simultaneously, the system assigns a corresponding defect severity score to each detected defect. This score is positively correlated with the severity of the defect. For example, the following severity mapping table can be predefined:

[0088] Fatal flaws (causing system crashes, data loss, etc.): Rating score is 10.

[0089] Critical defect (resulting in core functionality being unavailable): Rating 7 points;

[0090] General defect (causing non-core functional abnormalities): Level score is 4 points;

[0091] Minor defects (interface display issues, inaccurate prompts, etc.): rating 1 point.

[0092] For the same test case, if multiple defects of different levels are detected simultaneously, the system can accumulate the level scores corresponding to each defect to obtain the total defect detection level score for the test case, which is recorded as the defect detection level score. For example, if a test case detects one fatal defect and one general defect, its defect detection level score = 10 + 4 = 14.

[0093] S202. Determine the fitness score of each individual based on the weighted sum of the number of detected defects and the defect level scores of each individual.

[0094] After obtaining the number of detected defects and the defect level score for each individual, the system calculates the fitness score for that individual using a weighted summation method. The formula for calculating the fitness score is as follows:

[0095] Fitness score = W1 × number of detected defects + W2 × defect level score;

[0096] W1 and W2 are the weighting coefficients for the number of defects detected and the defect severity score, respectively. The values ​​of these two weighting coefficients can be dynamically adjusted according to the testing objectives: if more attention is paid to the number of defects found, a larger W1 can be set, such as W1=2, W2=1; if more attention is paid to the ability to detect serious defects, a larger W2 can be set, such as W1=1, W2=3.

[0097] Through the above calculations, each test case obtains a unique fitness score. The higher the fitness score, the stronger the test case's ability to discover defects in the target software. In subsequent selection operations, individuals with high fitness scores will have a greater probability of being selected as parents, thus passing on superior genes.

[0098] Figure 2 The method shown has the following technical effects:

[0099] By introducing a weighted sum of the number of detected defects and the defect level score, the defect detection capability of the test case is quantified into a specific value, enabling the genetic algorithm to select and optimize based on objective indicators. By adjusting the weight coefficients of the number of detected defects and the defect level score, users can flexibly control the optimization direction of the genetic algorithm.

[0100] Sub-step 2: Perform the selection operation:

[0101] Based on the fitness scores of each individual, the system uses strategies such as roulette wheel selection or tournament selection to select a certain number of individuals from the current population as parents. Individuals with higher fitness scores have a greater probability of being selected, thus preserving superior genes.

[0102] Sub-step 3: Perform crossover operation:

[0103] For the selected parent individuals, the system randomly pairs them and performs gene exchange on the paired individuals with a certain crossover probability (e.g., 0.8). The crossover operation simulates chromosome exchange in biological reproduction, with the aim of generating new offspring individuals. For example, the input parameters of two test cases can be crossovered to generate two new test cases. The location of the crossover point can be randomly selected.

[0104] Sub-step 4: Perform the mutation operation:

[0105] For newly generated offspring individuals, the system randomly alters their genes with a small mutation probability (e.g., 0.05). Mutation helps maintain population diversity and prevents premature convergence to local optima. For example, it can increase or decrease the value of an input parameter by a random amount, or change the order of test steps.

[0106] S104. After the preset termination condition is met, select the individuals with the highest fitness scores in the population of the final iteration round as the optimized test cases.

[0107] Repeat sub-steps 1-4 above until a preset termination condition is met. The termination condition may be reaching the maximum number of iterations (e.g., 100 rounds) or the highest fitness score of the population no longer increases (i.e., convergence) for multiple consecutive rounds.

[0108] When the evolutionary process terminates, the system selects a number of individuals with the highest fitness scores from the population in the final iteration. The number of individuals selected can be set according to actual needs, such as selecting the top 10% or the top 20 individuals. These selected individuals become the optimized test cases. Compared to the initial cases, the optimized test cases have undergone multiple rounds of evolution, possessing stronger defect detection capabilities and higher execution efficiency.

[0109] Furthermore, the system can format these optimized test cases through the output module. For example, it can convert them to Excel file format, add necessary header rows and data columns, and perform format validation to ensure data integrity. Simultaneously, the system can store these test cases in a local database or cloud storage system and provide an API interface for downstream test execution platforms to call, achieving automated integration with continuous integration tools.

[0110] Figure 1 The method shown has the following technical effects:

[0111] 1. By automatically extracting target test elements from the original test requirements information of the target software and generating multiple initial test cases in batches, compared to manually writing test cases, this method can systematically cover various test scenarios derived from the target test elements. This reduces omissions of boundary conditions, abnormal scenarios, and complex combination paths due to limitations in human subjective experience, effectively improving test coverage and reducing the risk of missed defects. Furthermore, this method of batch generating multiple initial test cases significantly improves the efficiency of initial test case production. When a large number of test cases need to be optimized subsequently, the automated evolutionary operation replaces manual modification, overcoming the problems of large workload and the potential for introducing new errors through manual modification.

[0112] 2. This method uses multiple initial test cases as an initial population and performs multiple iterations of evolutionary operations on the initial population. These evolutionary operations include: determining a fitness score (indicating defect detection capability) based on the test feedback data obtained after each test case is executed on the target software; and performing selection, crossover, and mutation operations using a genetic algorithm based on the fitness scores to generate the next round of the population. Finally, the individuals with the highest fitness scores are selected as optimized test cases. This approach constructs an optimized path of "execution-feedback-evolution" for test cases, overcoming the limited defect detection capability of manually written static test cases. Specifically, based on the characteristics of genetic algorithms, the fitness score quantifies the ability of each test case to actually expose defects in the target software; selection operations ensure that test cases with strong defect detection capabilities are retained; and crossover and mutation operations recombine test elements among cases to generate new case variants, exploring test path combinations that are difficult to exhaustively enumerate manually. Through multiple iterations, the population is continuously evolved, resulting in a set of optimized test cases consisting of individuals with the highest fitness scores. This leads to an optimized test case set with a defect detection capability far exceeding that of traditional manually written static test cases.

[0113] exist Figure 2 Based on the method shown, this embodiment further provides another method for calculating fitness scores. Figure 3 A flowchart illustrating the method for calculating fitness scores provided in this application embodiment. Figure 2 ,like Figure 3 As shown, the method includes:

[0114] S301. Obtain the code change coverage, redundancy score, and execution efficiency score for each individual. The code change coverage is used to indicate the ratio of the number of lines of code covered by an individual to the number of lines of code that have changed in the target software before the current iteration. The redundancy score is used to indicate the first similarity between an individual and other individuals in the population, and the redundancy score is inversely proportional to the first similarity. The execution efficiency score is used to indicate the execution time of an individual, and the execution efficiency score is inversely proportional to the execution time.

[0115] In this step, the system needs to calculate three metrics:

[0116] 1. Code change coverage:

[0117] This metric measures the coverage of recently changed code by test cases. Specifically, the system integrates with a version control system to obtain information on code changes to the target software prior to the current iteration, including the file paths, start line numbers, and end line numbers involved in the changes. When a test case is executed, the system records the actual lines of code executed by that case using code instrumentation or coverage tools. Then, it calculates the number of changed lines among the lines covered by the test case, divides this number by the total number of changed lines before the current iteration, and obtains a ratio, which is the code change coverage rate. For example, if there are a total of 100 changed lines, and a test case covers 30 of them, its code change coverage rate is 0.3 (or 30%). A higher ratio indicates that the test case is more effective at verifying newly modified code, helping to quickly identify regression defects introduced by code changes.

[0118] 2. Redundancy score:

[0119] This metric measures the similarity between a test case and other cases in the population, aiming to suppress redundant cases. Specifically, the system calculates the first similarity between pairs of test cases by comparing their genetic codes (such as input parameters, operation sequence sequences, etc.). Similarity can be calculated using methods such as edit distance, Jaccard similarity coefficient, or cosine similarity. For each individual, its redundancy score is defined as 1 minus the average similarity between that individual and all other individuals in the population, as shown in the formula:

[0120] Redundancy score = 1 - (average similarity with other individuals);

[0121] Therefore, it can be understood that the redundancy score is inversely proportional to the first similarity score: when a test case is highly similar to most other cases, its redundancy score approaches 0; when a test case is very unique and almost completely different from other cases, its redundancy score approaches 1. Introducing this metric can effectively avoid a large number of duplicate or highly similar cases in the population, maintain population diversity, and expand test coverage.

[0122] 3. Execution efficiency score:

[0123] This metric measures the execution time of test cases. The system records the time (in milliseconds or seconds) taken for each test case from start to finish. The execution efficiency score is defined as the reciprocal of the execution time of that test case, or a normalized relative value. For example, a baseline time (such as the shortest execution time in the population) can be set, and the execution efficiency score for each case can be calculated by dividing the baseline time by the actual execution time of that case. Thus, cases with shorter execution times have higher execution efficiency scores, and cases with longer execution times have lower scores. Introducing this metric can encourage the algorithm to retain cases that both discover defects and execute quickly, thereby improving overall testing efficiency.

[0124] S302. Calculate the weighted sum of the number of detected defects, defect level score, code change coverage, redundancy score, and execution efficiency score for each entity, and use it as the fitness score for each entity.

[0125] In this step, the calculation method for the number of detected defects and the defect level score can refer to the aforementioned embodiment.

[0126] Fitness score = W1 × number of defects detected + W2 × defect level score detected + W3 × code change coverage + W4 × redundancy score + W5 × execution efficiency score;

[0127] W1-W5 represent the weighting coefficients for each metric, which can be dynamically adjusted based on testing objectives and phases. For example, during the rapid iteration phase of agile development, higher W3 (code change coverage) and W5 (execution efficiency score) can be set to quickly verify new code and shorten the testing cycle; while during system stability testing, higher W1 and W2 can be set to maximize defect discovery capabilities. By default, all weights can be set to equal values, such as all being 1. Figure 3 The method shown has the following overall technical effects:

[0128] 1. The five dimensions of metrics are flexibly combined through weighting coefficients, allowing test case optimization to achieve a balance among multiple objectives such as defect detection capability, change coverage, diversity, and execution efficiency. Users can dynamically adjust the weights according to the testing needs at different stages to implement customized optimization strategies.

[0129] 2. Because the indicators for calculating fitness scores are more comprehensive and reasonable, genetic algorithms can more accurately evaluate the merits of each individual during the search process, reducing the risk of getting trapped in local optima. As a result, the final optimized test case set not only performs well in defect detection, but also has better targeting, diversity and execution efficiency.

[0130] Based on the aforementioned method for calculating fitness scores, this embodiment further provides a method for calculating the final fitness score. Figure 4 This is a schematic flowchart of a method for calculating the final fitness score provided in an embodiment of this application, as shown below. Figure 4 As shown, the method includes:

[0131] S401. Obtain code change information for the target software. The code change information is used to indicate the changed areas in the code of the target software.

[0132] Specifically, during the multi-round iterative evolution process, at the beginning of each iteration, the system connects to the version control system or code review tool to obtain the code change information of the target software since the previous iteration. This code change information includes, but is not limited to: the paths of newly added, deleted or modified code files; the names of changed functions, methods or classes; the range of changed code line numbers; and the type of change (such as adding features, fixing defects, refactoring, etc.).

[0133] S402. Based on the code change information, determine the correlation between each entity in the current iteration and the changed area;

[0134] In this step, for each test case (individual) in the population, the system analyzes its test steps, input parameters, expected results, and other attributes to determine the correlation between the test case and the code modification area. The correlation can be calculated using various methods, such as:

[0135] Text matching method: The text description of the test case (such as function name and page element name in the test steps) is matched with the file name, function name and variable name in the changed code. The higher the matching degree, the higher the relevance.

[0136] Call chain tracing: If the system has code coverage collection capabilities, it can record the lines of code covered by each test case during execution. If the lines of code covered by a certain test case overlap with the changed area, the correlation is calculated based on the overlap ratio. The higher the overlap ratio, the higher the correlation.

[0137] Static analysis method: By using static code analysis tools, a mapping relationship is established between test cases and code modules. For example, if test case A is specifically used to test the "user login" module, and the code change happens to occur in this module, then the correlation is high.

[0138] Ultimately, each individual receives a correlation score between 0 and 1, where 0 indicates no correlation and 1 indicates a high correlation.

[0139] S403. Based on the correlation degree of each individual, determine the weighting factor for each individual. The correlation degree is positively correlated with the magnitude of the weighting factor.

[0140] In this step, the system calculates a weighting factor for each individual based on the correlation degree. One possible implementation is a linear mapping: weighting factor = 1 + α × correlation degree, where α is an adjustable parameter greater than 0 (e.g., 2). Thus, an individual with a correlation degree of 0 has a weighting factor of 1 (no bonus), and an individual with a correlation degree of 1 has a weighting factor of 1 + α (maximum bonus). Similarly, a non-linear mapping, such as an exponential mapping, can be used to amplify the advantage of highly correlated individuals.

[0141] S404. Calculate the product of each individual's fitness score and the corresponding weighting factor, which is the final fitness of each individual.

[0142] In this step, after calculating the fitness score using the method described in the foregoing embodiments, the basic fitness score is multiplied by the weighting factor obtained in step S403 to obtain the final fitness score.

[0143] S405. Based on the final fitness of each individual, perform selection, crossover, and mutation operations on the population of the current iteration round to generate the population of the next iteration round.

[0144] The specific operation of the genetic algorithm in this step can be referred to the aforementioned embodiments.

[0145] Figure 4 The method shown has the following technical effects:

[0146] This method uses correlation weighting to enable the genetic algorithm to automatically prioritize test cases that can cover the changed code, thereby discovering potential defects in the new code more quickly within the same number of iterations and significantly improving the efficiency of regression testing.

[0147] Furthermore, using each individual's test elements as gene fragments, and based on each individual's final fitness, selection, crossover, and mutation operations are performed on the population of the current iteration round to generate the population of the next iteration round, including:

[0148] When performing the selection operation, the probability of each individual being selected as the parent individual is determined based on the final fitness and corresponding association degree of each individual. The association degree is positively correlated with the probability.

[0149] And / or,

[0150] When performing a crossover operation, increase the crossover probability of gene segments in the parent individual that are associated with the changed region;

[0151] And / or,

[0152] When performing mutation operations, increase the mutation probability of gene segments associated with the changed region.

[0153] Specifically, to further improve optimization efficiency, this embodiment introduces a fine-grained adjustment mechanism based on correlation, which is reflected in one or more of the following three aspects:

[0154] I. Probability Adjustment in Selection Operations:

[0155] When performing the selection operation, the system comprehensively considers the individual's final fitness and the correlation between the individual and the changed region to jointly determine the probability that the individual will be selected as the parent. The specific implementation method is as follows:

[0156] First, calculate a selection score for each individual, using the following formula:

[0157] Selection score = final fitness × (1 + β × association degree);

[0158] Here, β is an adjustable coefficient (e.g., β=1) used to control the strength of the influence of association on the selection probability. The higher the association, the higher the selection score. Then, a roulette wheel selection method is used to determine the probability of selection based on the proportion of each individual's selection score to the total score. In this way, even if two individuals have the same final fitness, the individual with a higher association with the changed region will have a greater selection probability, and is therefore more likely to pass on its genes to the next generation.

[0159] II. Probability Adjustment in Crossover Operations:

[0160] When performing a crossover operation, the system assigns different crossover probabilities to each gene segment (i.e., each test element of the test case, such as input parameters, operation steps, and expected results) in the parent individuals participating in the crossover. Specifically, for gene segments that are associated with the changed region, the system increases their crossover probability; for gene segments that are not associated with the changed region, it maintains a lower default crossover probability.

[0161] In one possible implementation, the system can pre-build a mapping table to record which gene segments in each test case are associated with the code-changed regions (e.g., a changed variable name corresponding to a certain input parameter, or a changed function involved in a certain operation step). During crossover, the system performs crossover on the entire gene set with a default crossover probability (e.g., 0.8), but for gene segments marked as "associated," an additional increment coefficient γ (e.g., γ=1.2) is applied, increasing their actual crossover probability to 0.96. This targeted enhancement helps to combine beneficial gene segments more frequently into new offspring, accelerating the fusion of superior traits.

[0162] III. Probability Adjustment in Mutation Operations:

[0163] When performing mutation operations, the system also differentiates gene fragments. For gene fragments that are associated with the modified region, the system increases their mutation probability; for unrelated gene fragments, it maintains a lower default mutation probability.

[0164] For example, the default mutation probability is set to 0.05, while for related gene fragments, the system increases the mutation probability to 0.15. This is done to encourage more exploratory changes to key, change-related test elements in order to discover new and more effective test cases. At the same time, for stable, change-independent gene fragments, a low mutation probability is maintained to avoid disrupting already optimized parts.

[0165] It should be noted that in practical applications, the three adjustment mechanisms mentioned above can be used independently or in combination. Taking the combination as an example, the operation process for each iteration is as follows:

[0166] Selection operation: Based on the selection score that combines final fitness and correlation, a roulette wheel selection is performed to select the parent individual;

[0167] Crossover operation: For the selected parent individuals, perform multi-point crossover according to the adjusted crossover probability (the crossover probability of gene segments associated with the changed region is higher) to generate offspring;

[0168] Mutation operation: For the generated offspring individuals, gene-by-gene mutation is performed according to the adjusted mutation probability (the mutation probability of gene segments associated with the changed region is higher) to produce the final new generation population.

[0169] exist Figure 1 Based on the method shown, to improve the parsing efficiency and accuracy of target test elements, a strategy based on historical parsing template reuse can be adopted. Based on this strategy, Figure 5 This is a schematic diagram of the process for extracting target test elements provided in an embodiment of this application, such as... Figure 5 As shown, the method includes:

[0170] S501. Based on the original test requirement information, calculate the second similarity between the feature vector of each historical test requirement information and the feature vector of the original test requirement information in the historical parsing record library.

[0171] The system pre-maintains a historical parsing record database, which stores all previously processed test requirement information and their corresponding parsing records. Each historical record includes at least: the full text or summary of the historical test requirement information, the feature vector of the requirement, and the historical parsing template (i.e., the feature parsing rule) used when successfully extracting test elements from the requirement. The feature vector is a numerical vector obtained by processing the requirement text using Term Frequency-Inverse Document Frequency (TF-IDF) or word embedding (such as Word2Vec), used to represent the semantic content of the requirement.

[0172] Upon receiving new original test requirement information, the system first performs the same feature vectorization process on the original requirement to obtain its feature vector. Then, it iterates through the historical parsing record database and calculates the cosine similarity between the feature vector of the original requirement and the feature vector of each historical test requirement, denoted as the second similarity. The second similarity value ranges from 0 to 1, with a higher value indicating that the two test requirement pieces of information are more semantically similar.

[0173] S502. Take the historical test requirement information whose corresponding second similarity reaches the preset threshold as the target test requirement information, and obtain the historical parsing template corresponding to the target test requirement information. The historical parsing template is used to indicate the element parsing rules for parsing the test elements of the target software from the target test requirement information.

[0174] In this step, the system can preset a similarity threshold (e.g., 0.85). If the second similarity corresponding to a certain historical test requirement information reaches or exceeds this threshold, the historical requirement is marked as the target test requirement information, and its associated historical parsing template is obtained.

[0175] It should be noted that this historical parsing template can be a set of element parsing rules. For example, for "user login" type requirements, the rules specify that elements such as "username input box", "password input box", "login button", "verification code", and "error message" should be extracted from the text, and the logical relationships between these elements are defined.

[0176] If the second similarity of multiple historical test requirement information reaches the threshold, the system can select the one with the highest second similarity, or generate a fusion template by combining multiple historical templates. If the second similarity of no historical test requirement information reaches the threshold, the system will revert to the general syntax parsing and semantic analysis method, such as the conventional parsing process based on a syntax parser and semantic analyzer as described above. After successful parsing, this parsing process will be stored in the database as a new historical parsing record for future reuse.

[0177] S503. Based on the element parsing rules indicated by the historical parsing template, the target test elements are parsed from the original test requirement information.

[0178] After obtaining a matching historical parsing template, the system performs targeted parsing of the current original test requirement information based on the element parsing rules indicated in the historical parsing template. During the parsing process, intelligent adaptation is required between the rules in the historical parsing template and the actual content of the original test requirement information. For example, if the historical parsing template specifies the extraction of "preconditions," the system searches for statements in the original requirement containing keywords such as "premise," "assumption," and "when," and extracts them using the sentence patterns recorded in the historical parsing template. Similarly, for elements such as "input data," "operation steps," and "expected results," the system also performs structured extraction according to the preset patterns in the historical parsing template.

[0179] Figure 5 The method shown has the following technical effects:

[0180] By calculating the similarity of feature vectors between the original test requirement information and the historical test requirement information, the most similar historical test requirement in the historical parsing records can be quickly matched. The mature historical parsing templates can be directly reused, avoiding repeated deep parsing processes. Especially for software test requirements of the same type and in the same field, the time spent parsing test elements can be greatly reduced.

[0181] Figure 6 This is a schematic diagram of the test case generation device provided in the embodiments of this application, such as... Figure 6 As shown, the device 60 includes:

[0182] Extraction module 601 is used to extract target test elements from the original test requirement information of the target software;

[0183] The generation module 602 is used to generate multiple initial test cases for the target software based on the target test elements.

[0184] Optimization module 603 is used to perform multiple iterations of evolutionary operations on the initial population, using multiple initial test cases as the initial population. The evolutionary operations include:

[0185] Based on the test feedback data obtained after each test case is executed on the target software in the current iteration of the population, the fitness score of each individual is determined. The fitness score is used to indicate the corresponding individual's ability to find defects in the target software.

[0186] Based on the fitness scores of each individual, the selection, crossover, and mutation operations of the genetic algorithm are performed on the population of the current iteration round to generate the population of the next iteration round.

[0187] Once the preset termination conditions are met, the individuals with the highest fitness scores in the final iteration of the population will be selected as the optimized test cases.

[0188] Figure 7 This is a schematic diagram of the electronic device structure provided in the embodiments of this application, such as... Figure 7 As shown, the device 70 includes at least one processor 701 and a memory 702. Optionally, the device 70 also includes a communication component 703. The processor 701, memory 702, and communication component 703 are connected via a bus 704.

[0189] In a specific implementation, at least one processor 701 executes computer execution instructions stored in memory 702, causing at least one processor 701 to perform the above-described method.

[0190] The specific implementation process of processor 701 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.

[0191] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.

[0192] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0193] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily essential to this application.

[0194] It should be further noted that although the steps in the flowchart are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the sub-steps or stages of other steps.

[0195] It should be understood that the above-described device embodiments are merely illustrative, and the device of this application can also be implemented in other ways. For example, the division of units / modules in the above embodiments is only a logical functional division, and there may be other division methods in actual implementation. For example, multiple units, modules, or components may be combined, or integrated into another system, or some features may be ignored or not executed.

[0196] Furthermore, unless otherwise specified, the functional units / modules in the various embodiments of this application can be integrated into one unit / module, or each unit / module can exist physically separately, or two or more units / modules can be integrated together. The integrated units / modules described above can be implemented in hardware or as software program modules.

[0197] When integrated units / modules are implemented in hardware, the hardware can be digital circuits, analog circuits, etc. The physical implementation of the hardware structure includes, but is not limited to, transistors, memristors, etc. Unless otherwise specified, the processor can be any suitable hardware processor, such as a CPU, GPU, FPGA, DSP, and ASIC, etc. Unless otherwise specified, the storage unit can be any suitable magnetic or magneto-optical storage medium, such as Resistive Random Access Memory (RRAM), Dynamic Random Access Memory (DRAM), Static Random Access Memory (SRAM), Enhanced Dynamic Random Access Memory (EDRAM), High-Bandwidth Memory (HBM), Hybrid Memory Cube (HMC), etc.

[0198] If the integrated unit / module is implemented as a software program module and sold or used as an independent product, it can be stored in a computer-readable storage device (CMD). Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned memory includes various media capable of storing program code, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard drive, magnetic disk, or optical disk.

[0199] In the above embodiments, the descriptions of each embodiment have their own emphasis. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments. The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as the combination of these technical features does not contradict each other, it should be considered within the scope of this specification.

[0200] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this application are indicated by the following claims.

[0201] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A test case generation method characterized by, The method comprises: extracting a target test element from original test requirement information of target software; generating a plurality of initial test cases of the target software based on the target test element; taking the plurality of initial test cases as an initial population, performing evolution operations of a plurality of iteration rounds on the initial population, the evolution operations comprising: determining fitness scores of each test case as an individual in the population of the current iteration round based on test feedback data obtained after the test case is executed on the target software, the fitness score being used to indicate the defect discovery capability of the corresponding individual on the target software; performing selection operation, crossover operation and mutation operation of a genetic algorithm on the population of the current iteration round based on the fitness score of each individual, to generate the population of the next iteration round; after the preset termination condition is met, taking a plurality of individuals with the highest fitness scores in the population of the final iteration round as optimized test cases.

2. The method of claim 1, wherein, The method comprises: obtaining the number of detected defects and the detected defect level score of each individual after the test case is executed on the target software, the detected defect level score being positively correlated with the severity of the detected defect; determining the fitness score of each individual based on the weighted sum of the number of detected defects and the detected defect level score of each individual.

3. The method of claim 2, wherein, The method comprises: obtaining the code change coverage, redundancy score and execution efficiency score of each individual, wherein the code change coverage is used to indicate the ratio of the number of code lines covered by the individual to the number of code lines changed before the current iteration round; the redundancy score is used to indicate the first similarity between the individual and other individuals in the population, and the redundancy score is inversely proportional to the first similarity; the execution efficiency score is used to indicate the execution time of the individual, and the execution efficiency score is inversely proportional to the execution time; calculating the weighted sum of the number of detected defects, the detected defect level score, the code change coverage, the redundancy score and the execution efficiency score of each individual as the fitness score of each individual.

4. The method according to any one of claims 1 to 3, characterized in that, The method comprises: obtaining code change information of the target software, the code change information being used to indicate the changed area in the code of the target software; determining the correlation degree between each individual of the current iteration round and the changed area based on the code change information; According to the correlation degree corresponding to each individual, a weighting factor corresponding to each individual is determined, and the correlation degree is positively correlated with the size of the weighting factor; A product of the fitness score of each individual and the corresponding weighting factor is calculated as the final fitness of each individual; Based on the final fitness of each individual, the selection operation, the crossover operation and the mutation operation are performed on the population of the current iteration round to generate the population of the next iteration round.

5. The method of claim 4, wherein, Based on the final fitness of each individual, the selection operation, the crossover operation and the mutation operation are performed on the population of the current iteration round to generate the population of the next iteration round, including: When the selection operation is performed, the probability of each individual being selected as a parent individual is determined based on the final fitness of each individual and the corresponding correlation degree, and the correlation degree is positively correlated with the probability; and / or, When the crossover operation is performed, the crossover probability of the gene segment associated with the change region in the parent individual is increased; and / or, When the mutation operation is performed, the mutation probability of the gene segment associated with the change region is increased.

6. The method of claim 1, wherein, The target test element is extracted from the original test requirement information of the target software, including: Based on the original test requirement information, the second similarity between the feature vector of each historical test requirement information in the historical analysis record library and the feature vector of the original test requirement information is calculated; The historical test requirement information corresponding to the second similarity reaching a preset threshold is taken as the target test requirement information, a historical analysis template corresponding to the target test requirement information is obtained, and the historical analysis template is used to indicate that the element analysis rule of the test element of the target software is analyzed from the target test requirement information; Based on the element analysis rule indicated by the historical analysis template, the target test element is analyzed from the original test requirement information.

7. The method of claim 1, wherein, Based on the target test element, a plurality of initial test cases of the target software are generated, including: The parameter value boundary of a target parameter in the target test element and the equivalent class of the target parameter are determined; A preset rule is called to generate a plurality of first test parameter values of the target parameter according to the parameter value boundary, and to generate a second test parameter value of the equivalent class; Based on the target test element, the first test parameter value and the second test parameter value, the initial test case is generated.

8. A test case generation apparatus characterized by comprising: The device includes: An extraction module is configured to extract a target test element from original test requirement information of a target software; A generation module is configured to generate a plurality of initial test cases of the target software based on the target test element; An optimization module is configured to take the plurality of initial test cases as an initial population, and perform evolution operations of a plurality of iteration rounds on the initial population, and the evolution operations include: According to test feedback data obtained after each test case as an individual in the population of the current iteration round is executed on the target software, an individual fitness score of each individual is determined, the individual fitness score being used to indicate a defect discovery capability of the corresponding individual on the target software; Based on the individual fitness score of each individual, a selection operation, a crossover operation and a mutation operation of a genetic algorithm are performed on the population of the current iteration round to generate the population of the next iteration round; After a preset termination condition is met, a number of individuals with the highest individual fitness score in the population of the final iteration round are used as optimized test cases.

9. An electronic device, comprising: Comprise: a processor, and a memory connected to the processor in communication; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory to implement the method of any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by the processor to implement the method of any one of claims 1 to 7.

11. A computer program product, characterised in that, The computer program is executed by the processor to implement the method of any one of claims 1 to 7.