Abstract:The goal of unit testing is to cover the functional logic of code unit, and internal inputs is the key of unit testing. Stub code has been used in most of the tools for c/c++ unit testing existed to solve the problem of internal inputs, while stub code may cause distortion of function, and it is difficult to solve these problems such as the uncontrollability and hard-initializing of underlying functions, the static inputs, the interrupt inputs, etc. To solve these problems, this paper proposed the underlying simulation technology for c/c++ unit testing, simulating and controlling the behavior of the sub-function in test cases, making the data generated by underlying function can be set in cases as the parameters, and it can simulate the local data and interrupt, avoid wasting time to write stub code, promote the testing efficiency.