The present invention provides a method of test cases reduction based on
program behavior slices. In the case that there is no need to scan all program paths, a
test suite capable of covering all program behaviors is generated to relieve the state-space explosion problem confronted by program tests. In the present invention, during a
static analysis stage, analyzing a
control flow and an information flow of a program according to input program codes, extracting control dependence and
data dependence of the program; calculating potential dependence of the program according to the control dependence and the
data dependence of the program; on the basis of the control dependence, the
data dependence and the potential dependence, constructing combination dependence of the program; during a dynamic execution stage, according to an execution path and the dependence relation, calculating
program behavior slices covered by the path and
program behavior slices uncovered by the path, and guiding
symbolic execution to generate a path capable of covering new program slices according to the uncovered program behavior slices. Compared with the existing
symbolic execution technique, the present invention can ensure the validity of the
test suite, while at the same time reducing the number of the generated test cases remarkably.