Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkMacroCreateDefaultTests.cmake
Go to the documentation of this file.
1 # Create TestDriver and default tests for MITK
2 #
3 # CMake variables used:
4 #
5 # ${${KITNAME}_GUI_TESTS} : filenames of all tests that run without a parameter
6 # ${${KITNAME}_IMAGE_GUI_TESTS : filenames of all tests that run with an image filename as parameter
7 # ${${KITNAME}_TESTS} : filenames of all tests that run without a parameter
8 # ${${KITNAME}_IMAGE_TESTS : filenames of all tests that run with an image filename as parameter
9 # ${${KITNAME}_TESTIMAGES} : list of images passed as parameter for the IMAGE_TESTS
10 # ${${KITNAME}_CUSTOM_TESTS} : filenames of custom tests which are just added to the TestDriver. Execution
11 # of these has to be specified manually with the ADD_TEST CMake command.
12 #
14  # add tests which need a GUI if it is not disabled
15  if(NOT MITK_GUI_TESTS_DISABLED)
16  set( ${KITNAME}_TESTS ${${KITNAME}_TESTS} ${${KITNAME}_GUI_TESTS} )
17  set( ${KITNAME}_IMAGE_TESTS ${${KITNAME}_IMAGE_TESTS} ${${KITNAME}_IMAGE_GUI_TESTS} )
18  endif()
19 
20  #
21  # Create the TestDriver binary which contains all the tests.
22  #
23  create_test_sourcelist(MITKTEST_SOURCE ${KITNAME}TestDriver.cpp
24  ${${KITNAME}_TESTS} ${${KITNAME}_IMAGE_TESTS} ${${KITNAME}_CUSTOM_TESTS}
25  )
26  add_executable(${KITNAME}TestDriver ${MITKTEST_SOURCE})
27  set_property(TARGET ${KITNAME}TestDriver PROPERTY LABELS ${PROJECT_NAME})
28  target_link_libraries(${KITNAME}TestDriver ${${KITNAME}_CORE_LIBRARIES} ${${KITNAME}_LIBRARIES} ${LIBRARIES_FOR_${KITNAME}_CORE})
29  #
30  # Now tell CMake which tests should be run. This is done automatically
31  # for all tests in ${KITNAME}_TESTS and ${KITNAME}_IMAGE_TESTS. The IMAGE_TESTS
32  # are run for each image in the TESTIMAGES list.
33  #
34  foreach( test ${${KITNAME}_TESTS} )
35  get_filename_component(TName ${test} NAME_WE)
36  add_test(${TName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KITNAME}TestDriver ${TName})
37  set_property(TEST ${TName} PROPERTY LABELS ${PROJECT_NAME})
38  endforeach()
39 
40  foreach(image ${${KITNAME}_TESTIMAGES} ${ADDITIONAL_TEST_IMAGES} )
41  if(EXISTS "${image}")
42  set(IMAGE_FULL_PATH ${image})
43  else()
44  # todo: maybe search other paths as well
45  # yes, please in mitk/Testing/Data, too
46  set(IMAGE_FULL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/Data/${image})
47  endif()
48 
49  if(EXISTS "${IMAGE_FULL_PATH}")
50  foreach( test ${${KITNAME}_IMAGE_TESTS} )
51  get_filename_component(TName ${test} NAME_WE)
52  get_filename_component(ImageName ${IMAGE_FULL_PATH} NAME)
53  add_test(${TName}_${ImageName} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${KITNAME}TestDriver ${TName} ${IMAGE_FULL_PATH})
54  set_property(TEST ${TName}_${ImageName} PROPERTY LABELS ${PROJECT_NAME})
55  endforeach()
56  else()
57  message("!!!!! No such file: ${IMAGE_FULL_PATH} !!!!!")
58  endif()
59  endforeach()
60 endmacro()
61 
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.
Definition: testcase.h:32
MITK_CREATE_DEFAULT_TESTS()
static bool in(Reader::Char c, Reader::Char c1, Reader::Char c2, Reader::Char c3, Reader::Char c4)
Definition: jsoncpp.cpp:244
const std::string TARGET