Software test case generation method based on firefly algorithm

By introducing the attraction and randomization coefficient of the firefly algorithm in software test case generation, combined with the gravity between populations, the problem of intelligent optimization algorithms falling into local optimality is solved, the quality and efficiency of test cases are improved, and a more comprehensive software is realized Function coverage.

CN118626382APending Publication Date: 2024-09-10HENAN UNIV OF URBAN CONSTR
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410802974.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-20
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing intelligent optimization algorithms are prone to falling into local optimal solutions when generating software test cases, resulting in reduced test coverage and efficiency, and are unable to fully cover software functions and ensure test quality.

Method used

A software test case generation method based on the firefly algorithm is adopted. By introducing the firefly attractiveness and randomization coefficient related to the number of iterations, and setting the gravity based on the position relationship between populations, the firefly position update formula is improved, the global search ability of the algorithm is enhanced, and the local minimum is avoided. Optimize the solution and improve convergence efficiency.

Benefits of technology

It effectively improves the reduction rate and fault detection rate of test cases, ensures the quality and efficiency of software testing, and improves the coverage and convergence performance of test cases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626382A
    Figure CN118626382A
Patent Text Reader

Abstract

The invention discloses a software test case generation method based on a firefly algorithm, and belongs to the field of software testing, the method takes a test reduction rate and a fault detection rate as objective functions and adopts the firefly algorithm for optimization, and the development and exploration capability of firefly algorithm search is enhanced by changing the value of a fixed parameter. And improving a firefly position updating formula by using the randomization coefficient and the firefly attraction coefficient according to the number of iterations, and limiting the moving direction of the firefly population which is far away from the firefly population by setting and introducing a formula for gravitational force between the firefly populations, so as to ensure that the two populations can still attract each other and move through the gravitational force when the distance between the two populations is far away. According to the improved algorithm, the convergence speed of the algorithm can be increased, the capacity of obtaining a globally optimal solution can be improved, a better software test case reduction result can be obtained, and meanwhile good convergence performance is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method for generating software test cases based on a firefly algorithm. Background Art

[0002] With the development of computer technology, various software products are constantly updated. Software testing is an effective means to ensure software quality, and software testing cannot be separated from test cases. Generally, the more functions the software to be tested has, the higher the requirements, and the faster the version update iteration, so more and more comprehensive test cases need to be generated. If the generation and screening of these test cases rely entirely on manual labor, the efficiency and quality of software testing will face huge challenges. Therefore, in order to overcome the defects of traditional test case generation methods, software test case automatic generation technology came into being.

[0003] Intelligent optimization algorithms are algorithms that are inspired by certain phenomena in nature or the genetics and evolution of animal populations. They are widely used in solving optimization problems and generating software test cases. In the software testing process, intelligent algorithms are used to reduce test cases, add test cases, prioritize test cases, and select test cases, thereby improving the coverage and efficiency of software testing applications. However, in the process of generating test cases through optimization algorithms, the global optimal solution is usually obtained, which reduces the test case coverage, resulting in the inability of software test cases to fully cover software functions and the inability to guarantee the quality of test cases. Summary of the invention

[0004] In view of the defects of the prior art, the present invention proposes a method, device and storage medium for generating software test cases based on the firefly algorithm. The update position of the fireflies is limited by introducing the firefly attraction and randomization coefficient related to the number of iterations, and the gravity between populations is set in combination with the position relationship between populations. This avoids the situation in which the test coverage and test efficiency are reduced in the process of obtaining the global optimum by generating test cases using an intelligent optimization algorithm, thereby ensuring the test quality and efficiency.

[0005] The present invention provides a method for generating software test cases based on the firefly algorithm, the method comprising the following steps:

[0006] Step 1: Select multiple functional modules in the software and combine them as the test content, obtain the source code and test case set of each functional unit, and select the test reduction rate and fault detection rate as the test case evaluation criteria respectively;

[0007] The test reduction rate calculation formula includes:

[0008]

[0009] Where RS is the test reduction rate, T0 is the number of test cases in the original test case set, and T is the number of test cases in the optimized test case set;

[0010] The fault detection rate calculation formula includes:

[0011]

[0012] Where FA is the fault detection rate, F is the number of software error cases detected by the full coverage detection method, and F' is the number of software error cases detected by the optimized detection method.

[0013] Step 2: Set the maximum number of algorithm iterations I max , determine the population size of fireflies, set the initial position of individuals and population positions, and initialize the population and individual parameters;

[0014] This application can set a specific value of the maximum number of iterations based on the scale and dimension of the software test set during the actual optimization process performed by technical personnel in this field.

[0015] Step 3: According to the positions of individuals and populations, the absolute brightness of individual and group fireflies is calculated through the objective function;

[0016] Step 4: Calculate the relative brightness and attraction of two firefly individuals based on the formula for the relative brightness of fireflies and the formula for attraction between individuals;

[0017] Since the attractiveness of a firefly is proportional to the light intensity seen by its neighbors, we can now denote the attractiveness of a firefly β(r ij ) is defined as

[0018]

[0019] Among them, β0 is the maximum attraction of fireflies, γ is the fixed light absorption coefficient, r ij is the Euclidean distance from firefly i to firefly j, and its calculation formula is as follows:

[0020]

[0021] In the formula, x i is the position of the i-th firefly; x j is the position of the jth firefly; k is the serial number of the position dimension, D is the position dimension; x ik is the value of the jth dimension of the i-th firefly; x jk is the value of the kth dimension of the jth firefly;

[0022] Step 5: According to the firefly position update formula, calculate the update of individual positions in the population. The brightest firefly in the population moves irregularly, and its position change can be calculated using a separate calculation formula.

[0023] This application enhances the development and exploration capabilities of algorithm search by changing the values ​​of fixed parameters. For the original firefly algorithm, multiple predetermined and fixed parameter values ​​in the motion equation are updated, randomization and attraction parameters are pre-set in the initialization phase, and then modified during the optimization process. In the iterative process, the local search capability of the algorithm is enhanced to avoid the optimization results from falling into the local optimum; at the same time, the firefly algorithm has a smaller search radius and non-directivity in the optimization process, and thus still has a significant randomization factor. Therefore, the local search capability is improved by improving the local optimal solution and the global optimal solution during the search process to avoid the non-directivity of the algorithm search, and finally the algorithm quickly obtains the global optimal solution.

[0024] The improved firefly algorithm focuses on broadening the movement area of ​​individual and population fireflies. Fireflies tend to move towards fireflies with higher brightness. If the brightness of firefly i is lower than that of firefly j, firefly j is attracted to firefly i and moves closer to it. Then, the position of firefly i is updated by improving the firefly position update formula. The firefly position update formula is:

[0025]

[0026] in

[0027]

[0028] In the formula, t is the time variable, x i (t) is the position of firefly i at time t+1, x i (t+1) is the position of firefly i at time t, is the firefly attraction coefficient that changes with the number of iterations, α(I) is the randomization coefficient that changes with the number of iterations, I represents the current number of iterations, and I max represents the maximum number of iterations, and a is the randomness attenuation coefficient.

[0029] The first two terms in the firefly position update formula represent the attraction relationship between fireflies, and the last term broadens the firefly's spatial exploration ability to prevent it from falling into the local optimum. In addition, the firefly attraction coefficient Combined with the randomization coefficient α(I) to modify the position update formula. Therefore, during the search process, the firefly attraction will increase adaptively, while the randomization coefficient will decrease as the algorithm execution time or number of iterations increases.

[0030] In the early stage of algorithm optimization, the randomization coefficient α(I) is set to a maximum value, and the firefly attraction coefficient Set to a minimum value to ensure that all fireflies are in a random moving state in the early stage, thereby preventing the algorithm from converging too early in the early stage of optimization and falling into the local optimal problem. Therefore, by setting the randomization coefficient α(I) and the firefly attraction coefficient that change with the number of iterations It can effectively improve the firefly population and individual diversity, thereby enhancing the algorithm's global search capability and improving the reliability of the optimization results. Setting it to a higher value increases the light intensity, making the fireflies at the sweet spot brighter, thus moving other fireflies with lower brightness closer to the sweet spot. Also, by setting the randomization factor to a very small value, you can move fireflies closer to the sweet spot, thus increasing the light intensity of the fireflies.

[0031] Step 6: After the firefly individuals in the population are updated, the absolute brightness of each new firefly individual must be recalculated;

[0032] Step 7: Get the relative brightness of the firefly population and the distance between the populations, and set the attraction between the firefly populations according to the relative brightness and position of the firefly populations;

[0033] In the initial stage, there are multiple brightest individuals in different populations that attract fireflies with lower brightness within a specific range. As the number of iterations increases, there are no firefly individuals between firefly populations, and the perception range of firefly individuals is limited, and they can only move within a specific range. The update of firefly individuals and populations becomes smaller and smaller, resulting in a large population distance. As a result, two firefly populations that are far apart cannot attract each other, which leads to the algorithm falling into the local optimum and slow convergence. Therefore, by setting the gravity between firefly populations, it is ensured that when the two populations are far apart, they can still attract each other through gravity, thereby improving the convergence efficiency of the algorithm and the ability to obtain the global optimal solution. The gravity formula between firefly populations is:

[0034] F att-ij =δ|q i -q j |×|C i -C j |

[0035] In the formula, qi represents the relative position of the i-th firefly population, q j represents the relative position of the jth firefly population. The relative position of the firefly population is obtained by calculating the mean relative position of each firefly in the population. δ is the gravitational coefficient, C i and C jThey represent the light intensity of firefly population i and the light intensity of firefly population j respectively, and are obtained by summing the light intensity of each individual firefly in the population.

[0036] By setting the attraction between the two populations, the two firefly populations that are relatively far away are attracted to each other and moved closer to each other. At the same time, the firefly population with smaller light intensity is set to move closer to the firefly population with larger light intensity. For example, when C i >C j When C i <C j When C i =C j When the gravitational force of the firefly population is randomly set and pointed to any direction, the population is forced to move closer, thereby improving the comprehensiveness of the algorithm search.

[0037] Step 8: Update the position of the firefly population according to the gravity of the firefly population, and update the calculation of the light intensity of the firefly population;

[0038] Step 9: Determine whether the algorithm meets the termination condition of the maximum number of iterations. If so, terminate the algorithm and obtain the final result. If not, repeat the steps until the algorithm ends; output the optimization result.

[0039] To achieve the above objective, according to another aspect of an embodiment of the present invention, a software test case generation device based on a firefly algorithm is provided.

[0040] The software test case generation device based on the firefly algorithm described in the present invention includes one or more processors; a storage device for storing one or more computer programs, when the one or more computer programs are executed by the one or more processors, the one or more processors implement the method steps as described above.

[0041] To achieve the above objective, according to another aspect of an embodiment of the present invention, a computer readable medium is provided.

[0042] The computer-readable medium of the embodiment of the present invention stores a computer program, and when the program is executed by a processor, the method described above is implemented.

[0043] The beneficial technical effects brought by the present invention are as follows: in view of the problem that the firefly algorithm is prone to fall into the local optimum too early in the existing test case reduction process, the present invention proposes a software test case generation method based on the firefly algorithm, which uses the firefly algorithm for optimization with the test reduction rate and the fault detection rate as the objective function, enhances the development and exploration ability of the firefly algorithm search by changing the value of the fixed parameter, and improves the firefly position update formula by the randomization coefficient and the firefly attraction coefficient according to the number of iterations, thereby enhancing the local search ability of the firefly while avoiding the firefly from falling into the local optimal solution too early, and improving the probability of the algorithm finding the global optimal solution; in view of the problem that the firefly algorithm converges slowly in the later stage of optimization, the gravitational formula between firefly populations is introduced to limit the moving direction of firefly populations that are far apart, ensuring that when the two populations are far apart, they can still attract each other and move through gravity, thereby improving the convergence speed of the algorithm and the ability to obtain the global optimal solution. The improved firefly algorithm of the present invention can effectively solve the test case reduction problem, effectively improve the reduction rate, reduce the error detection rate, obtain better software test case reduction results, and also has good convergence performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 The present invention is a flowchart of a method for generating software test cases based on the firefly algorithm.

[0045] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0046] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0047] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.

[0048] The present invention provides a method for generating software test cases based on the firefly algorithm, the method comprising the following steps:

[0049] Step 1: Select multiple functional modules in the software and combine them as the test content, obtain the source code and test case set of each functional unit, and select the test reduction rate and fault detection rate as the test case evaluation criteria respectively;

[0050] The test reduction rate calculation formula includes:

[0051]

[0052] Where RS is the test reduction rate, T0 is the number of test cases in the original test case set, and T is the number of test cases in the optimized test case set;

[0053] The fault detection rate calculation formula includes:

[0054]

[0055] Where FA is the fault detection rate, F is the number of software error cases detected by the full coverage detection method, and F' is the number of software error cases detected by the optimized detection method.

[0056] Step 2: Set the maximum number of algorithm iterations I max , determine the population size of fireflies, set the initial position of individuals and population positions, and initialize the population and individual parameters;

[0057] Step 3: According to the positions of individuals and populations, the absolute brightness of individual and group fireflies is calculated through the objective function;

[0058] Step 4: Calculate the relative brightness and attraction of two firefly individuals based on the formula for the relative brightness of fireflies and the formula for attraction between individuals;

[0059] Since the attractiveness of a firefly is proportional to the light intensity seen by its neighbors, we can now denote the attractiveness of a firefly β(r ij ) is defined as

[0060]

[0061] Among them, β0 is the maximum attraction of fireflies, γ is the fixed light absorption coefficient, r ij is the Euclidean distance from firefly i to firefly j, and its calculation formula is as follows:

[0062]

[0063] In the formula, x i is the position of the i-th firefly; x j is the position of the jth firefly; k is the serial number of the position dimension, D is the position dimension; x ik is the value of the jth dimension of the i-th firefly; x jk is the value of the kth dimension of the jth firefly;

[0064] Step 5: According to the firefly position update formula, calculate the update of individual positions in the population. The brightest firefly in the population moves irregularly, and its position change can be calculated using a separate calculation formula.

[0065] This application enhances the development and exploration capabilities of algorithm search by changing the values ​​of fixed parameters. For the original firefly algorithm, multiple predetermined and fixed parameter values ​​in the motion equation are updated, randomization and attraction parameters are pre-set in the initialization phase, and then modified during the optimization process. In the iterative process, the local search capability of the algorithm is enhanced to avoid the optimization results from falling into the local optimum; at the same time, the firefly algorithm has a smaller search radius and non-directivity in the optimization process, and thus still has a significant randomization factor. Therefore, the local search capability is improved by improving the local optimal solution and the global optimal solution during the search process to avoid the non-directivity of the algorithm search, and finally the algorithm quickly obtains the global optimal solution.

[0066] The improved firefly algorithm focuses on broadening the movement area of ​​individual and population fireflies. Fireflies tend to move towards fireflies with higher brightness. If the brightness of firefly i is lower than that of firefly j, firefly j is attracted to firefly i and moves closer to it. Then, the position of firefly i is updated by improving the firefly position update formula. The firefly position update formula is:

[0067]

[0068] in

[0069]

[0070] In the formula, t is the time variable, x i (t) is the position of firefly i at time t+1, x i (t+1) is the position of firefly i at time t, is the firefly attraction coefficient that changes with the number of iterations, α(I) is the randomization coefficient that changes with the number of iterations, I represents the current number of iterations, and I max represents the maximum number of iterations, and a is the randomness attenuation coefficient.

[0071] The first two terms in the firefly position update formula represent the attraction relationship between fireflies, and the last term broadens the firefly's spatial exploration ability to prevent it from falling into the local optimum. In addition, the firefly attraction coefficient Combined with the randomization coefficient α(I) to modify the position update formula. Therefore, during the search process, the firefly attraction will increase adaptively, while the randomization coefficient will decrease as the algorithm execution time or number of iterations increases.

[0072] In the early stage of algorithm optimization, the randomization coefficient α(I) is set to a maximum value, and the firefly attraction coefficient Set to a minimum value to ensure that all fireflies are in a random moving state in the early stage, thereby preventing the algorithm from converging too early in the early stage of optimization and falling into the local optimal problem. Therefore, by setting the randomization coefficient α(I) and the firefly attraction coefficient that change with the number of iterations It can effectively improve the firefly population and individual diversity, thereby enhancing the algorithm's global search capability and improving the reliability of the optimization results. Setting it to a higher value increases the light intensity, making the fireflies at the sweet spot brighter, thus moving other fireflies with lower brightness closer to the sweet spot. Also, by setting the randomization factor to a very small value, you can move fireflies closer to the sweet spot, thus increasing the light intensity of the fireflies.

[0073] Step 6: After the firefly individuals in the population are updated, the absolute brightness of each new firefly individual must be recalculated;

[0074] Step 7: Obtain the relative brightness of the firefly population and the distance between the populations, and set the attraction between the firefly populations according to the relative brightness and distance of the firefly populations;

[0075] In the initial stage, there are multiple brightest individuals in different populations that attract fireflies with lower brightness within a specific range. As the number of iterations increases, there are no firefly individuals between firefly populations, and the perception range of firefly individuals is limited, and they can only move within a specific range. The update of firefly individuals and populations becomes smaller and smaller, resulting in a large population distance. As a result, two firefly populations that are far apart cannot attract each other, which leads to the algorithm falling into the local optimum and slow convergence. Therefore, by setting the gravity between firefly populations, it is ensured that when the two populations are far apart, they can still attract each other through gravity, thereby improving the convergence efficiency of the algorithm and the ability to obtain the global optimal solution. The gravity formula between firefly populations is:

[0076] F att-ij =δ|q i -q j |×|C i -C j |

[0077] In the formula, qi represents the relative position of the i-th firefly population, q j represents the relative position of the jth firefly population. The relative position of the firefly population is obtained by calculating the mean relative position of each firefly in the population. δ is the gravitational coefficient, C i and C j They represent the light intensity of firefly population i and the light intensity of firefly population j respectively, and are obtained by summing the light intensity of each individual firefly in the population.

[0078] By setting the attraction between the two populations, the two firefly populations that are relatively far away are attracted to each other and moved closer to each other. At the same time, the firefly population with smaller light intensity is set to move closer to the firefly population with larger light intensity. For example, when C i >C j When C i <C j When C i =C j When the gravitational force of the firefly population is randomly set and pointed to any direction, the population is forced to move closer, thereby improving the comprehensiveness of the algorithm search.

[0079] Step 8: Update the position of the firefly population according to the gravity of the firefly population, and update the calculation of the light intensity of the firefly population;

[0080] Step 9: Determine whether the algorithm meets the termination condition of the maximum number of iterations. If so, terminate the algorithm and obtain the final result. If not, repeat the steps until the algorithm ends; output the optimization result.

[0081] To achieve the above objective, according to another aspect of an embodiment of the present invention, a software test case generation device based on a firefly algorithm is provided.

[0082] The software test case generation device based on the firefly algorithm described in the present invention includes one or more processors; a storage device for storing one or more computer programs, when the one or more computer programs are executed by the one or more processors, the one or more processors implement the method steps as described above.

[0083] The methods executed by the above-mentioned programs can refer to the various embodiments of the method of the present invention, which will not be described in detail here.

[0084] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity / operation / object from another entity / operation / object, and do not necessarily require or imply any such actual relationship or order between these entities / operations / objects; the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0085] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts refer to the partial description of the method embodiment. The device embodiment described above is only illustrative, and the units described as separate components may or may not be physically separated. Some or all of the modules can be selected according to actual needs to achieve the purpose of the scheme of the present invention. Those of ordinary skill in the art can understand and implement it without paying creative work.

[0086] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0087] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment method can be implemented by means of software plus a necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, including a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the software test case generation method based on the firefly algorithm described in each embodiment of the present invention.

[0088] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A method for generating software test cases based on the firefly algorithm, characterized in that: The method includes the following steps: Step 1: Select multiple functional modules in the software and combine them as the test content, obtain the source code and test case set of each functional unit, and select the test reduction rate and fault detection rate as the test case evaluation criteria respectively; Step 2: Set the maximum number of algorithm iterations I max , determine the population size of fireflies, set the initial position of individuals and population positions, and initialize the population and individual parameters; Step 3: According to the positions of individuals and populations, the absolute brightness of individual and group fireflies is calculated through the objective function; Step 4: Calculate the relative brightness and attraction of two firefly individuals based on the formula for the relative brightness of fireflies and the formula for attraction between individuals; Step 5: According to the firefly position update formula, calculate the update of individual positions in the population. The brightest firefly in the population moves irregularly, and its position change can be calculated using a separate calculation formula. Step 6: After the firefly individuals in the population are updated, the absolute brightness of each new firefly individual must be recalculated; Step 7: Obtain the relative brightness of the firefly population and the distance between the populations, and set the attraction between the firefly populations according to the relative brightness and distance of the firefly populations; Step 8: Update the position of the firefly population according to the gravity of the firefly population, and update the calculation of the light intensity of the firefly population; Step 9: Determine whether the algorithm meets the termination condition of the maximum number of iterations. If so, terminate the algorithm and obtain the final result. If not, repeat the steps until the algorithm ends; output the optimization result.

2. The method for generating software test cases based on the firefly algorithm according to claim 1, characterized in that: The step 1 is specifically as follows: the test reduction rate calculation formula includes: Where RS is the test reduction rate, T0 is the number of test cases in the original test case set, and T is the number of test cases in the optimized test case set; The fault detection rate calculation formula includes: Where FA is the fault detection rate, F is the number of software error cases detected by the full coverage detection method, and F' is the number of software error cases detected by the optimized detection method.

3. The method for generating software test cases based on the firefly algorithm according to claim 1, characterized in that: Step 4 is as follows: Since the attractiveness of a firefly is proportional to the light intensity seen by its neighboring fireflies, we can now calculate the attractiveness of the firefly β(r ij ) is defined as Among them, β0 is the maximum attraction of fireflies, γ is the fixed light absorption coefficient, r ij is the Euclidean distance from firefly i to firefly j, and its calculation formula is as follows: In the formula, x i is the position of the i-th firefly; x j is the position of the jth firefly; k is the serial number of the position dimension, D is the position dimension; x ik is the value of the jth dimension of the i-th firefly; x jk is the value of the kth dimension of the jth firefly.

4. The method for generating software test cases based on the firefly algorithm according to claim 1, characterized in that: The step 5 includes: the firefly position update formula is: in, In the formula, t is the time variable, x i (t) is the position of firefly i at time t+1, x i (t+1) is the position of firefly i at time t, is the firefly attraction coefficient that changes with the number of iterations, α(I) is the randomization coefficient that changes with the number of iterations, I represents the current number of iterations, and I max represents the maximum number of iterations, and a is the randomness attenuation coefficient.

5. The method for generating software test cases based on the firefly algorithm according to claim 1, characterized in that: The step 5 includes: the gravitational force formula between firefly populations is: F att-ij =δ|q i -q j |×C i -C j | In the formula, q i represents the relative position of the i-th firefly population, q j represents the relative position of the jth firefly population. The relative position of the firefly population is obtained by calculating the mean relative position of each firefly in the population. δ is the gravitational coefficient, C i and C j They represent the light intensity of firefly population i and the light intensity of firefly population j respectively, and are obtained by summing the light intensity of each individual firefly in the population.

6. The method for generating software test cases based on the firefly algorithm according to claim 5, characterized in that: The method further comprises: when C i >C j When C i <C j When C i =C j When the gravitational force of the firefly population is randomly set and directed to any direction, forcing the population to move closer.

7. A software test case generation device based on firefly algorithm, characterized in that: The device includes one or more processors; a storage device for storing one or more computer programs, when the one or more computer programs are executed by the one or more processors, the one or more processors implement the method steps described in any one of claims 1-6.

8. A computer-readable storage medium, characterized in that: The stored computer program enables the electronic device to execute the method for generating software test cases based on the firefly algorithm as described in any one of claims 1 to 6.