A little background on the project: we as a company receive a spaghetti source code, and into that we add even more spaghetti code. So with that I want to say that complete restructuring the code and un-spaghettifing it is not really possible, and we also do not have any say in what the other company deliveries, we just have to deal with what we have.
It is a C/C++11 code with CMake. I chose Google test framework (but I can still change it).
The structure is something like this
src/ModuleA/
├── CMakeLists.txt
├── include
│ ├── Submodule1
│ │ ├── Submodule1.h
│ │ └── SomethingElse
│ │ └── SomethingElse.h
│ └── ModuleA.h
└── src
├── Submodule1
│ ├── Submodule1.c
│ └── SomethingElse
│ └── SomethingElse.c
└── ModuleA.cpp
Naturally there are tons of modules, submodules, headers and source files
And ofcourse they include each other all over the place and between the big Modules!
Now the question – what steps would you recommend to a noob unit-tester (I’m actually a developer, not tester) to best tackle this problem. Sure, I know that I have to “isolate” the UUT, but that is easier said than done. What folder structure would you recommend? And what CMake structure would you recommend to make it easily manageable in the future (reusing mocks/fakes, untouched headers) to avoid manually adding tons of code for each unit over and over.
Tomáš Viks Pilný is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1