Add tests
This commit is contained in:
parent
a3a5277e5d
commit
3fd27905ee
7 changed files with 1429 additions and 0 deletions
140
tests/CMakeLists.txt
Normal file
140
tests/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
cmake_minimum_required(VERSION 4.0)
|
||||
|
||||
# Enable testing
|
||||
enable_testing()
|
||||
|
||||
# Find Qt packages for tests
|
||||
find_package(Qt6 COMPONENTS Core Gui Widgets Multimedia Test REQUIRED)
|
||||
|
||||
# Define common sources needed by all tests - include only what's actually needed for basic testing
|
||||
set(COMMON_TEST_SOURCES
|
||||
../src/items/item.h
|
||||
../src/items/item.cpp
|
||||
../src/sensors/sensor.h
|
||||
../src/sensors/sensor.cpp
|
||||
../src/programmode.h
|
||||
../src/programmode.cpp
|
||||
../src/microcontroller.h
|
||||
../src/microcontroller.cpp
|
||||
../src/actors/actor.h
|
||||
../src/actors/actor.cpp
|
||||
../src/actors/factoractor.h
|
||||
../src/actors/factoractor.cpp
|
||||
../src/actors/polynomalactor.h
|
||||
../src/actors/polynomalactor.cpp
|
||||
../src/actors/sensoractor.h
|
||||
../src/actors/sensoractor.cpp
|
||||
../src/actors/timeractor.h
|
||||
../src/actors/timeractor.cpp
|
||||
../src/items/relay.h
|
||||
../src/items/relay.cpp
|
||||
../src/items/messageitem.h
|
||||
../src/items/messageitem.cpp
|
||||
../src/items/systemitem.h
|
||||
../src/items/systemitem.cpp
|
||||
../src/items/auxitem.h
|
||||
../src/items/auxitem.cpp
|
||||
../src/items/poweritem.h
|
||||
../src/items/poweritem.cpp
|
||||
../src/items/rgbitem.h
|
||||
../src/items/rgbitem.cpp
|
||||
../src/actors/alarmtime.h
|
||||
../src/actors/alarmtime.cpp
|
||||
../src/actors/regulator.h
|
||||
../src/actors/regulator.cpp
|
||||
../src/items/itemsource.h
|
||||
../src/items/itemsource.cpp
|
||||
../src/items/itemstore.h
|
||||
../src/items/itemstore.cpp
|
||||
../src/items/itemloadersource.h
|
||||
../src/items/itemloadersource.cpp
|
||||
)
|
||||
|
||||
# Add test executables - compile all needed sources into each test
|
||||
add_executable(test_item unit/items/test_item.cpp ${COMMON_TEST_SOURCES})
|
||||
add_executable(test_sensor unit/sensors/test_sensor.cpp ${COMMON_TEST_SOURCES})
|
||||
add_executable(test_actor unit/actors/test_actor.cpp ${COMMON_TEST_SOURCES})
|
||||
add_executable(test_itemstore unit/items/test_itemstore.cpp ${COMMON_TEST_SOURCES})
|
||||
add_executable(test_itemloadersource unit/items/test_itemloadersource.cpp ${COMMON_TEST_SOURCES})
|
||||
|
||||
# Link libraries for test_item
|
||||
target_link_libraries(test_item
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Multimedia
|
||||
Qt6::Test
|
||||
)
|
||||
|
||||
# Include paths for source files
|
||||
target_include_directories(test_item PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
${Qt6Gui_PRIVATE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Link libraries for test_sensor
|
||||
target_link_libraries(test_sensor
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Multimedia
|
||||
Qt6::Test
|
||||
)
|
||||
|
||||
# Include paths for source files
|
||||
target_include_directories(test_sensor PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
${Qt6Gui_PRIVATE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Link libraries for test_actor
|
||||
target_link_libraries(test_actor
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Multimedia
|
||||
Qt6::Test
|
||||
)
|
||||
|
||||
# Include paths for source files
|
||||
target_include_directories(test_actor PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
${Qt6Gui_PRIVATE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Link libraries for test_itemstore
|
||||
target_link_libraries(test_itemstore
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Multimedia
|
||||
Qt6::Test
|
||||
)
|
||||
|
||||
# Include paths for source files
|
||||
target_include_directories(test_itemstore PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
${Qt6Gui_PRIVATE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Link libraries for test_itemloadersource
|
||||
target_link_libraries(test_itemloadersource
|
||||
Qt6::Core
|
||||
Qt6::Gui
|
||||
Qt6::Widgets
|
||||
Qt6::Multimedia
|
||||
Qt6::Test
|
||||
)
|
||||
|
||||
# Include paths for source files
|
||||
target_include_directories(test_itemloadersource PRIVATE
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/../src
|
||||
${Qt6Gui_PRIVATE_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
# Add tests to CTest
|
||||
add_test(NAME test_item COMMAND test_item)
|
||||
add_test(NAME test_sensor COMMAND test_sensor)
|
||||
add_test(NAME test_actor COMMAND test_actor)
|
||||
add_test(NAME test_itemstore COMMAND test_itemstore)
|
||||
add_test(NAME test_itemloadersource COMMAND test_itemloadersource)
|
||||
Loading…
Add table
Add a link
Reference in a new issue