4

In the test that I want to run using CTest I should be adding the test that I want to run, with the following command:

add_test(TestName ExeName)

The problem is what if I want to supply an argument to the TestName, where do I put it? How do I run ctest individually without cmake in unix command line in this context?

mpromonet
  • 11,326
  • 43
  • 62
  • 91

2 Answers2

3

Insert the following command in the CMakeLists.txt file:

ENABLE_TESTING()

Next add the test(s):

add_test(testname Executable args)

To determine what tests are available, you can always run:

ctest -N

The second way of specifying tests is using explicit test number option -I:

ctest -I 3

will run the test number 3.

Nadir SOUALEM
  • 3,451
  • 2
  • 23
  • 30
2

Arguments are passed after the executable name just like in the command line.

enable_testing()

add_test(FirstTest app.exe 100)
add_test(SecondTest app.exe 200)
add_test(ThirdTest app.exe 300)

Tests can be run based on the "index" of the test with the -I option.

ctest -I 2,3

Specific tests can be run based on the test name too with the -R option.

ctest -R "Second"
ap-osd
  • 2,624
  • 16
  • 16