The application relates to the technical field of
software test
automation, and provides a requirement-driven
test case automatic generation method and
system based on a semantic
test graph, which comprises the following steps: performing multidimensional
static analysis on
source code, respectively constructing an
abstract syntax tree, a
control flow graph and a function
call graph, and extracting function call relations and data flow dependency relations; taking a function as a node, taking a function call relation as a main edge, and taking a data flow
dependency relation as an auxiliary edge to construct a semantic
test graph; aggregating function nodes in the semantic
test graph into a plurality of function modules; obtaining a plurality of test requirement nodes, calculating
semantic similarity between the test requirement nodes and the function modules, establishing a mapping relation from the test requirement nodes to the function modules, and forming a requirement-
program structure association graph; based on the requirement-
program structure association graph, generating a test intention for each test requirement node, and converting the test intention into an
executable test case. The highly corresponding relation between the generated
test case and the business requirement is ensured.