feat(test): add a macro saver to generate GUI test skeletons
Description
In !650 (merged), I have created a GUI library that allows to create GUI tests. However, creating GUI tests still isn't that simple, especially to get the graphic components to interact with. MacroSaver will generate a GUI test skeleton compatible with GuiTester to save that hassle. To use MacroSaver, one must call sightrun with the --macro
flag, the generated tests will be available once the application is closed as the files "GuiTest.cpp" and "GuiTest.hpp".
Closes #810 (closed)
How to test it?
Unfortunately, I didn't manage to test automatically MacroSaver, as it requires to compile the generated tests. One can test it manually however. To do so, you must firstly call sightrun with the --macro
flag, for example bin/sighrun path/to/profile.xml --macro
or bin/sightviewer --macro
. Then, you may either compile the generated tests as an in-tree test or as a out-of-tree project.
For the former, simply put the generated tests in a new directory in the source tree, the CMakeLists.txt should contain something like sight_add_target(macroSaverTest TYPE GUI_TEST)
, after configuring/compiling, it should be executable as bin/macroSaverTest. Don't forget to add_subdirectory
this new directory.
For the latter, you must have a version of Sight installed with GuiTester inside (either from this branch or from gui-qtest branch). Create a new directory and put the generated tests inside. MacroSaver doesn't create a main function, so you'll either have to create it, or the file cmake/build/cppunit_main.cpp should do the trick. A minimal working CMakeLists.txt would be
cmake_minimum_required(VERSION 3.22)
add_executable(macroSaverTest GuiTest.cpp GuiTest.hpp cppunit_main.cpp)
find_package(sight COMPONENTS guiTest REQUIRED)
find_package(Qt5 COMPONENTS Test REQUIRED)
target_link_libraries(macroSaverTest sight::guiTest)
Don't forget to set up the sight_DIR
variable when configuring. After compiling, it should be executable as LD_LIBRARY_PATH="$SIGHT_INSTALLATION_PATH/lib" ./macroSaverTest``.