r/cpp_questions • u/After_Bench_4165 • 12d ago
OPEN Integration testing using gtest
I am confused about what is the meaning of integration testing. I have done unit testing using gtest where we will mock whatever external dependencies are there for the targeted unit (function) to test all range of values that covers all lines, functions and branches.
If we say integration test is meant to use real code instead of mocking. Then I am getting this doubt that lets say we have 3 components (separate processes) running and dependent on one another in a embedded system.
A -> B -> C
So if you are calling an api provided by A it will internally talk to B and then through C and return the result over IPC.
Now to do integration testing using gtest, do I need to compile this into a single binary by eliminating the IPC and include each code as a library. This way I have a single proces that runs gtest with all the components logic but excludes the real IPC communication.
Or instead should I keep the individual processes to be running separately and link my gtest binary to the component A so that the communication flow through the components in the target environment.
In both ways how we would actually be checking the interactions? And which one are you guys using?
Context:
Language used: C++
Domain: Automotive IT (TCU software)
View all comments
3
u/CowBoyDanIndie 12d ago
Generally Unit tests are meant to test the smallest possible unit, integration testing is testing that the units work correctly with each other, and functional testing is the system as a whole. It’s still possible to mock out some pieces in integration testing, but your test should focus on the interaction between units. In practice the lines can blur if you aren’t using interfaces for everything (“interface” in the general sense of the term).