The invention belongs to the field of
software testing, and relates to an ROS 2
software package defect detection method based on a large
language model and coverage rate guidance. According to the method, function information is extracted from a to-be-tested program, and a
regular expression is used for analyzing
function definition, parameter characteristics and other information; the method comprises the following steps: presetting
verification standards related to a to-be-tested program, and extracting physical constraints and document constraints from the
verification standards; integrating the extracted function information, physical constraint and document constraint into accurate information, filling a cue word template with the accurate information, inputting the cue word template into a large
language model, and generating an initial test seed; a
mutation strategy is introduced, and diversified
mutation operation is performed on the generated seeds, so that test cases with higher diversity are generated; optimizing the
test case by adopting a coverage rate guiding mechanism, and guiding to generate a new
test case by monitoring the coverage rate in real time; through a defect
verification mechanism, dominant defects such as program
crash and the like can be detected, and hidden defects such as violation of physical constraints or violation of document constraints and the like can be identified.