I have project in which I want to use check library for unit testing.
My current project is using CMake and has following structure:
.
├── CMakeLists.txt
├── COPYING
├── ChangeLog
├── README
├── src
│ ├── core
│ │ ├── CMakeLists.txt
│ │ └── main.c
│ ├── core-test
│ │ ├── CMakeLists.txt
│ │ └── main.c
│ └── scrypt
└── doc
└── protocol.txt
In core-test I have unit tests for core module. In scrypt-test I will have tests for scrypt module and so on.
Does using check with CTest make sense?
If yes: how do I connect unit test that use check to CMake/CTest project? Do I need additional configuration for CTest to interpret results from check-enabled executables?
Using
checkwith CTest is possible, unfortunately not convenient.When unit tests using
checkfail they will be counted as a failure in CTest. The problem is, that CTest doesn’t show output of application that failed1. The other downside is that CTest doesn’t count individualchecktests, so a “single” failed test could mean multiplechecktests. I wasn’t able to find a way to make CTest interpret check results.You can force printing of output by creating
CTestCustom.cmakefile in build directory (the same one in which you runmakeorctest) with following contents:set (CTEST_CUSTOM_POST_TEST “cat Testing/Temporary/LastTest.log”)