Hi, I am currently creating some unit test for my C code with google test (test case written in C++), but I have some trouble in implementing it. Sorry if my question are all over the place, I was quite lost.
A.c & A.h has function X, Y, and Z. X will call Y, Y will call Z.
A_Mock.cc & A_Mock.h has mock class with function X_Mock, Y_Mock, and Z_Mock.
To unit test function X, I would have to use Y_Mock. My current solution is by using conditional compilation to isolate each function, and using macros to select either actual or mock function depending on which function to test. Although this works, I would have to create a lot of unit test file (3 utest files for each function in A), and more if module A grows with more function call stack. Is there a simpler way to isolate each function?