Question

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?

Was it helpful?

Solution

Using check with CTest is possible, unfortunately not convenient.

When unit tests using check fail 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 individual check tests, so a "single" failed test could mean multiple check tests. I wasn't able to find a way to make CTest interpret check results.


  1. You can force printing of output by creating CTestCustom.cmake file in build directory (the same one in which you run make or ctest) with following contents:

    set (CTEST_CUSTOM_POST_TEST "cat Testing/Temporary/LastTest.log")

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top