Using CMake, how do I get verbose output from CTest?

You could call ctest directly, after cmaking and making your project.

ctest --verbose

  1. You can check the Testing/Temporary subfolder. It is automatically created after running make test. This folder contains two files: LastTest.log and LastTestsFailed.log. LastTest.log contains desired output for run tests. LastTestFailed.log contains names of failed tests. So you can check them manually after executing make test.

  2. The second way is to get ctest to show you the content of log files after running tests:

    1. place in build dir (from which you run make test) file CTestCustom.ctest (you can do it with configure file command, for example) with following contents

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

Instead of cat you may use whatever Windows cmd command that does similar things.

  1. run make test again and get profit!

additional info about customizing ctest you can find here. Just step to "Customizing cmake" section. Good luck!


You can set the environment variable CTEST_OUTPUT_ON_FAILURE, which will show you any output from the test program whenever the test fails. One way to do this when using Makefiles and the command line would be as follows:

env CTEST_OUTPUT_ON_FAILURE=1 make check

This Stack Overflow question and answer shows how to set environment variables in Visual Studio.

Tags:

Cmake

Ctest