The invention discloses a C + + Mock class automatic generation method based on an inverse memory agent and a contrast
knowledge graph, and aims to solve the problems that a
virtual function coverage gap in a large C / C + + code
library is difficult to find, the Mock
code maintenance cost is high, and the automatic repair efficiency is low. According to the method, a difference context matrix is constructed by analyzing and merging request patch
metadata, and an incremental
abstract syntax tree is generated; generating a
backtracking queue based on the event intensity and the semantic overlapping degree, and extracting a
virtual function change
list; the multi-scale difference extraction is completed in combination with an external expansion operator according to the rule that the path is not disassembled and the node is movable; a self-adaptive strategy table and a Mock specification are generated, through code synthesis and lightweight compilation
verification, automatic self-healing is achieved through
root cause positioning and minimum cost repair, finally, a result is written into a
knowledge graph, and parameters are dynamically adjusted. According to the invention, Mock generation accuracy and version adaptability are improved, manual intervention is reduced, and test maintenance efficiency is improved.