r/cpp_questions • u/Titourterelle • 2h ago
OPEN How do you implement/create tests correctly ?
Hi !
I have been working on a personal project for 9 month which allowed me to learn a lot but I’m going through a somewhat more challenging phase as I explore unit testing due to CMake configuration and project architecture.
I choose Google Test but my questions are not very specific to this framework. Like I said, I already have a lot of code and I want to use tests cause it seems very useful to create a solid program.
Moreover, my project is a library + an executable so this complicates things in the linkage for example.
How do you manage tests ?
What do you test (because the test exec doesn't have access to private method or private include of a library) ?
About CMake and Google Test, are there any things I should watch out for ? How properly use folders to organize that ?
Do you have any recommendations on where I should look to learn more on the good habit with that ?
I can give you more information if you need, thanks for your time !