The invention discloses a method for automatically generating a dynamic language
test case based on a large
language model, which comprises the following steps of: firstly, in a preprocessing stage, arranging related information of a to-be-tested program into prompts, analyzing a
parameter type of the to-be-tested program by the large
language model according to the prompts, and generating code information required by a test through an
abstract syntax tree; in the
test case generation stage, a dynamic multi-objective optimization
algorithm is adopted, test cases are continuously crossed and mutated through
branch coverage feedback, in the partial evolution process,
test data which cannot be generated by conventional variation are generated by utilizing a large
language model, and finally, the screened excellent test cases are organized into a complete
test suite. In a program repair phase, the
test suite is run to detect potential errors, the errors are analyzed and iteratively repaired using a large language model, and an
executable and error-free
test suite is generated. According to the method, the test coverage rate of the dynamic language is remarkably improved, and the achievement of a coverage target is accelerated.