The application discloses a
test case generation method based on a
genetic algorithm and local search of
reinforcement learning, and comprises the following steps: performing
static analysis on a program to be tested, and constructing a
control flow graph and a data flow graph; enumerating
executable paths, analyzing the dependency relationship between the paths and input variables, and constructing a path dimension matrix; randomly generating an initial
population, and calculating fitness based on
branch distance; performing selection,
crossover and
mutation operations of the
genetic algorithm under the constraint of the path dimension matrix; selecting elite individuals, introducing local search of
reinforcement learning, and adjusting variables on relevant dimensions through the local search of
reinforcement learning to reduce
branch distance; and outputting test cases covering target paths when a termination condition is met. The application identifies key variables through the path dimension matrix, focuses on a search space, finely adjusts elite individuals through local search of reinforcement learning, overcomes the problem of
slow convergence in the later stage of the
genetic algorithm, realizes the cooperation of global exploration and local optimization, and improves the efficiency and success rate of
path coverage testing of a complex program.