KWWidgets/GUI Testing/Squish/SquishForKWWidgets

From KitwarePublic
Jump to navigationJump to search

Goals

  • Create a CMake module to find Squish on the system (paths to Squish server and Squish runner).
  • Create CMake macros that will run a Squish test by invoking the squish server and client runner, and parsing its output,
  • Invoke the Squish module when configuring/building KWWidgets,


Files

The following files are added to the KWWidgets/CMake directory.

  • FindSquish.cmake: locates Squish and sets SQUISH_FOUND. (This script is written by Brad Davis)
 NOTE: The SQUISH_ADD_TEST macro defined here should not be used by KWWidgets since KWWidgets has some special requirements to run Squish tests. Instead, 
 the KWWidgets_ADD_Squish_TEST macro, defined in KWWidgetsTestingMacro.cmake, should be used to add squish tests to CTest.
  • KWWidgetsSquishTestScript.cmake: implements Squish testing sequence (start server, run test, stop server, by invoking SquishRunTestCase.sh).
 (This script is based on the SquishTestScript.cmake written by Brad Davis)
  • SquishRunTestCase.sh: The actual shell script to be launched by KWWidgetsSquishTestScript.cmake. (This shell script is written by Brad Davis)
  • KWWidgets_ADD_Squish_TEST macro is defined in KWWidgetsTestingMacro.cmake.
# KWWidgets_ADD_Squish_TEST

macro(KWWidgets_ADD_Squish_TEST 
    test_name
    squish_AUT_full_path
    squish_test_case_path
    aut_env
    aut_path_script
    aut_args
    )

  set(kwwSquishShellScript "${KWWidgets_CMAKE_DIR}/SquishRunTestCase.sh")

  # Can only handle "Tk"
  set(squish_script_wrapper "Tk")

  ADD_TEST(${test_name}
    ${CMAKE_COMMAND} -V -VV --test
    "-Dsquish_aut:STRING=${squish_AUT_full_path}"
    "-Dsquish_server_executable:STRING=${SQUISH_SERVER_EXECUTABLE}"
    "-Dsquish_client_executable:STRING=${SQUISH_CLIENT_EXECUTABLE}"
    "-Dsquish_libqtdir:STRING=${QT_LIBRARY_DIR}"
    "-Dsquish_test_case:STRING=${squish_test_case_path}"
    "-Dsquish_env_vars:STRING=${aut_env}"
    "-Dsquish_wrapper:STRING=${squish_script_wrapper}"
    "-Dsquish_aut_script:STRING=${aut_path_script}"
    "-Dsquish_shell_script:STRING=${kwwSquishShellScript}"
    "-Dsquish_aut_args:STRING=${aut_args}"
    -P "${KWWidgets_CMAKE_DIR}/KWWidgetsSquishTestScript.cmake"
    ${ARGN})

endmacro(KWWidgets_ADD_Squish_TEST)

Use

The following CMakeLists.txt file shows how to add a Squish test to a KWWidgets Cxx Example project, for example, Examples/Cxx/WidgetsTour . A "KWWidgets_TEST_WITH_Squish" option is added to KWWidgets CMakeLists.txt, and by default it is OFF, so you have to turn it ON to add squish tests, given SQUISH_FOUND is true.


find_package(Squish)

if(BUILD_TESTING AND KWWidgets_BUILD_TESTING)
  include("${KWWidgets_CMAKE_DIR}/KWWidgetsTestingMacros.cmake")
  kwwidgets_add_test_from_c_example(KWWidgets-${PROJECT_NAME} ${EXE_NAME})

  if(KWWidgets_TEST_WITH_Squish AND SQUISH_FOUND)
    set(Squish_TST_NAME "${KWWidgets_SOURCE_DIR}/Examples/Cxx/${PROJECT_NAME}/Testing/Squish/suite_KWWTourExample/tst_BrowseCoreWidgets")
    kwwidgets_add_squish_test_from_c_example(
      KWWidgets-Squish-${PROJECT_NAME} ${EXE_NAME} "${Squish_TST_NAME}")    
  endif(KWWidgets_TEST_WITH_Squish AND SQUISH_FOUND)

endif(BUILD_TESTING AND KWWidgets_BUILD_TESTING)