I have a small project written primarily in C++ which is documented with Doxygen and tested with a unit testing framework (Google Test in my case, but that doesn't matter). I wrote several test cases for each method of each class to test the method's behavior under various conditions, and I want to leave some comments for the test suites. The Doxygen documentation is designed for projet's user, who very likely does not want to see the documents for projects implementation details and tests.

I want to know what is the common strategy of unit test documentation? Do not comment them at all and consider the tests themselves as documentation? Or maybe leave non-doxygen comments in the test files? Or use doxygen's ENABLED_SECTIONS option to compile test documentation conditionally?


ENABLED_SECTIONS is the way to go. Then you can easily switch them on for those who want them (yourself, colleagues, maintainers) and off for those who don't (the project's user).

That's what we do & it works just fine.

  • 1
    Thanks for your answer! And how do you enable those sections? Do you have a flag in your build system (i.e. -DENABLE_FOO_TEST_DOCUMENTATION for CMake command line) or you just edit the Doxyfile each time you need test docs? – Sergey Jul 7 '16 at 14:45
  • From the build system. We have a few Eclipse configurations for development and one for relase. We use Jenkins to build those, and they add the -D or not, as appropriate. – Mawg Jul 7 '16 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.