The invention discloses a method for evolving and generating
path coverage test data facing defects, which aims to
expose the defects in a target path as much as possible from the generated
test data so as to effectively enhance the quality of the
test data. The method comprises the following steps of: firstly, establishing a math model for generating the
path coverage test data facing the defects by using a path, in which the largest number of defects are found during tested procedure execution by the test data and the danger level of the defects is highest, as a target under the condition of a restraint that the test data must pass through the target path; and secondly, designing a restraining method for optimizing a plurality of targets so as to solve the problem, and evolving and generating the through target path by using a
genetic algorithm, and effectively exposing the test data of the defects at the same time. By the method, the problem that the test data generated by the conventional method can only just pass through the target path instead of effectively exposing the defects in the target path, in particular some small-probability defects, can be solved; and the method can be used for generating the test data for a
white box test or a regression test, so the efficiency of the
software test can be improved greatly.