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; constructing a semantic
test graph by taking functions as nodes, taking function call relations as main edges and taking data flow dependency relations as auxiliary edges, and aggregating function nodes in the semantic
test graph into several function modules; obtaining several test requirement nodes, calculating
semantic similarity between the test requirement nodes and the function modules, establishing a mapping relationship from the test requirement nodes to the function modules, and forming a requirement-
program structure association graph; and 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 relationship between the generated
test case and the business requirement is ensured.