Computer Assited Medical Intervention Tool Kit  version 4.0
Modules | Functions

CamiTK CMake macros used for testing. More...

Modules

 level
 CamiTK CMake macros used generating the mediawiki tab containing the list of all functionnal tests, classified by CamiTK extensions with their given LEVEL.
 

Functions

 camitk_add_test ()
 camitk_add_test is a macro to add a new test to the CTest infrastructure It encapsulates CMake add_test and adds useful way of testing programs. More...
 
 camitk_init_test ()
 camitk_init_test is a macro to initialize a group of test (for the same command) It is used to initialize a series of tests for a given target. More...
 

Detailed Description

CamiTK CMake macros used for testing.

Function Documentation

◆ camitk_add_test()

camitk_add_test ( )

camitk_add_test is a macro to add a new test to the CTest infrastructure It encapsulates CMake add_test and adds useful way of testing programs.

It cannot operate on its on, you need to call camitk_init_test first (and only once) before calling camitk_add_test

Details on the runned test can be found in ${CMAKE_BINARY_DIR}/Testing/Temporary/target# where target is the executable name (see camitk_init_test() macro), and # is the test order number.

Usage:

camitk_add_test(EXECUTABLE_ARGS "arg1 arg2 arg3"
PASS_FILE pristineOutput
PASS_REGULAR_EXPRESSION regexp
FAIL_REGULAR_EXPRESSION regexp
PROJECT_NAME name
TEST_SUFFIX name
)
Parameters
EXECUTABLE_ARGS(optional) The executable arguments (all in double quotes), typically each test will have different arguments. Can be empty
PASS_FILE(optional) If specified the test to perform is to compare the output of the command to this file. It the output is the same, then the test is passed, otherwise it is failed.
PASS_REGULAR_EXPRESSION(optional) This is equivalent to "PASS_REGULAR_EXPRESSION regexp" property for the test, see http://www.cmake.org/Wiki/CTest:FAQ#My_test_does_not_return_non-zero_on_failure._What_can_I_do.3F
FAIL_REGULAR_EXPRESSIONThis is equivalent to "FAIL_REGULAR_EXPRESSION regexp" property for the test, see http://www.cmake.org/Wiki/CTest:FAQ#My_test_does_not_return_non-zero_on_failure._What_can_I_do.3F
PROJECT_NAMEBase name for the test, can be used for ctest -S
TEST_SUFFIXSuffix added to the test name, just after PROJECT_NAME and before the test index

If no argument are given, it does the equivalent as add_test(name target)

Note
You can only choose one between nothing, PASS_FILE, PASS_REGULAR_EXPRESSION and FAIL_REGULAR_EXPRESSION

Example invocation:

add_executable(myprogram)
...
# Start the test series for myprogram
camitk_init_test(myprogram)
camitk_add_test(EXECUTABLE_ARGS "-a inputfile.xml -c" PASS_FILE pristineOuputToCompareTo.xml) # will be called myprogram1
...
camitk_add_test(...) # myprogram2
See also
camitk_init_test

Referenced by camitk_extension().

◆ camitk_init_test()

camitk_init_test ( )

camitk_init_test is a macro to initialize a group of test (for the same command) It is used to initialize a series of tests for a given target.

Usually this is placed in the same CMakeLists.txt as the add_executable() cmake instruction or camitk_application() macro

It does few useful things:

  • check if the application is properly defined
  • initialize test id (then automatically incremented in camitk_test_declare
  • initialize test output directory

Usage:

camitk_init_test(applicationname)
Parameters
applicationname(required) The name of the test application (in camitk context, name of the project

Example invocation:

...
# Start the test series for myprogram
camitk_init_test(myprogram)
camitk_add_test(...) # will be called myprogram1
...
camitk_add_test(...) # myprogram2
See also
camitk_add_test

Referenced by camitk_extension().