The invention provides a method for automatically generating 
software test cases. The method comprises the following steps of: A. reading to-be-tested 
software, carrying out 
lexical analysis, 
syntax analysis and semantic analysis on a source program of the to-be-tested 
software and generating an 
abstract syntax tree and a 
control flow graph of the to-be-tested software; B. preprocessing the source program of the to-be-tested software by traversing the generated 
abstract syntax tree, identifying initial input-output variables and compressing the space of a definition domain of the initial input variables; and C. generating a path of program elements of the current to-be-tested software by traversing the 
control flow graph, carrying out assignment operation, implication operation and 
backtracking operation on the variables in the path, and generating the test cases. The invention also provides a 
system for automatically generating software test cases. The method and the 
system for automatically generating the software test cases can accurately and automatically generate the test cases according to the given program elements of the to-be-tested software and verify the generated test cases, thereby improving the accuracy, efficiency and 
automation degree of the test cases.