Questions tagged [ctest]

Is the CMake test driver program.

Is the CMake test driver program. Many CMake command related to testing are related to CTest, too.

Most of the documentation is part of CMake's documentation, like the documentation concerning the CTest executable.

298 questions
158
votes
12 answers

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

I'm using CMake to build my project. I have added a unit test binary which is using the Boost unit testing framework. This one binary contains all of the unit tests. I've added that binary to be run by CTest: ADD_EXECUTABLE( tftest test-main.cpp…
Skrymsli
  • 5,173
  • 7
  • 34
  • 36
109
votes
11 answers

CMake & CTest : make test doesn't build tests

I'm trying CTest in CMake in order to automatically run some of my tests using make test target. The problem is CMake does not "understand" that the test I'm willing to run has to be built since it is part of the project. So I'm looking for a way to…
claf
  • 9,043
  • 17
  • 62
  • 79
44
votes
2 answers

CMake: setting an environmental variable for ctest (or otherwise getting failed test output from ctest/make test automatically)

I want ctest to show me the failed tests output by default. That is, I want to run: $ make all test and see any output of failed tests without having to cat Testing/Temporary/LastTest.log. It appears that there are two ways of doing this: (1)…
Jeet
  • 38,594
  • 7
  • 49
  • 56
40
votes
3 answers

Expected build-failure tests in CMake

Sometimes it's good to check that certain things fail to build, e.g.: // Next line should fail to compile: can't convert const iterator to iterator. my_new_container_type::iterator it = my_new_container_type::const_iterator(); Is it possible to…
Ami Tavory
  • 74,578
  • 11
  • 141
  • 185
34
votes
3 answers

Producing CTest results in Jenkins (xUnit >= 1.58)

It seems like this should be easy to integrate CMake+CTest in jenkins. The cmakebuilder plugin is extremely easy to configure (just set the source tree and the build tree, done!). However I fail to understand how to call the CTest steps. According…
malat
  • 12,152
  • 13
  • 89
  • 158
34
votes
1 answer

How to run ctest after building my project with cmake

I want my tests to be launched each time my project is successfully built. And if some tests are broken I want my build to be broken too. By default I need to run tests manually by running ctest command. CTest can actually build project but I use…
Evgeny Lazin
  • 9,193
  • 6
  • 47
  • 83
33
votes
1 answer

CTest not detecting tests

I have a project with a structure ├── CMakeLists.txt ├── mzl.c ├── mzl.h └── tests ├── CMakeLists.txt ├── mzl-communication-test.c ├── mzl-setup-test.c ├── mzl-test-errors.c └── mzl-test-errors.h Where the top directory…
Daniel Underwood
  • 2,191
  • 2
  • 22
  • 48
31
votes
2 answers

Build Qt Tests with CMake

Can anyone give me an example of some QT test code and a CMakeLists.txt that build with Cmake and ran with CTest. I can't seem to find any! -Kurtis
Kurtis Nusbaum
  • 30,445
  • 13
  • 78
  • 102
31
votes
3 answers

How to pass command-line arguments in CTest at runtime

I'm using CTest and want to pass command-line arguments to the underlying tests at runtime. I know there are ways to hard code command-line arguments into the CMake/CTest script, but I want to specify the command-line arguments at runtime and have…
jlconlin
  • 14,206
  • 22
  • 72
  • 105
29
votes
1 answer

Run ctest from different directory than build directory used by cmake?

I would like to be able in a similar manner as I can run cmake like cmake --build to run ctest like ctest --build Obviously running ctest from the will work, but it would be nice if I can just tell…
user1357687
  • 571
  • 1
  • 6
  • 9
26
votes
0 answers

How to do code coverage in cmake

I want to use code coverage tools(lcov) in my cmake project. I read the example here https://github.com/bilke/cmake-modules/blob/master/CodeCoverage.cmake The tests are added in my project using the 'add_test()' cmake function. I want to create a…
Monku
  • 2,440
  • 4
  • 33
  • 57
25
votes
2 answers

Catch lib (unit testing) and CTest (CMake) integration

I'm looking for successful example of Catch CatchLib integration with CMake test (Ctest) . as I understand this is additional cmake script which has to parse application ouput? Did someone already written this? probably shared this?…
amigo421
  • 2,429
  • 4
  • 26
  • 55
24
votes
2 answers

How to get CTest results in Hudson / Jenkins

I'm using CTest (part of CMake) for my automated tests. How do I get CTest results in the Jenkins dashboard ? Or, phrased differently, how do I get CTest to output in JUnit-like XML ?
Calvin1602
  • 9,413
  • 2
  • 44
  • 55
24
votes
1 answer

How to overwrite Ctest default timeout 1500 in CMakeLists.txt

My CMakeLists.txt includes the lines include(CTest) enable_testing() set(CTEST_TEST_TIMEOUT 3) add_test(...) ctest works, but ignores my attempt to set the timeout. Rather, it runs with the default timeout of 1500. How to change the default…
Joachim W
  • 7,290
  • 5
  • 31
  • 59
20
votes
1 answer

How to adapt my unit tests to cmake and ctest?

Until now, I've used an improvised unit testing procedure - basically a whole load of unit test programs run automatically by a batch file. Although a lot of these explicitly check their results, a lot more cheat - they dump out results to text…
user180247
1
2 3
19 20