Reputation: 4112
I am currently refactoring parts of a qt/c++ application for my company and they have absolutely no unit tests.
I would like to add some, but I actually never did the setup for testing so I am not 100% sure of the best way to proceed. Here is what I was thinking (feel free to comment on this, but it is not my main question)
My question is: How do I (or should I) prevent the test classes to be compiled / included in release? I mean, if I manage to get a large test coverage, this will be plenty of new test code to compile, which is useless for the application itself. Can we (should we) exclude this code in release versions? What is the common practice (if there is one)?
Upvotes: 0
Views: 577
Reputation: 26
If you are using CMake, in your CMakeLists, you can define what files are used in your current build.
In the same CMake, you can define a different target that includes your tests files. The location of the files don't matter, they can be in the same place as your code
Upvotes: 1