mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-16 01:48:42 -05:00
* options work a bit better ,now services and apps are selectable by option in cmake * test service example added * major documentation for module-services * documentation for project configs and logs Co-authored-by: Bartosz Cichocki <sp2fet@gmail.com> Co-authored-by: Mateusz Piesta <mateusz.piesta@mudita.com>
1.7 KiB
1.7 KiB
Adding unit tests
Preface
We use either:
to write unit tests.
You can add as many test targets as you wish.
IMPORTANT: All tests are run on the CI on PR's automatically
How to use
Unit tests are always in catalog test or tests and should be included with
NOTE: see the one letter difference!
if (${ENABLE_TESTS})
add_subdirectory(test)
endif ()
NOTE: To see how test gathering works please see: CMake for UT
To add test target use either of functions:
add_catch2_executable or add_gtest_executable
Both take arguments:
NAMEtest name, it will be prefixed withcatch2_orgoogletest_, depending on your suite choiceSRCS- sources for your unit testsINCLUDE- include directories (-I) for your testLIBS- libraries you depend onDEFS- defines you want to pass to the testDEPS- dependencies you want to pass to the testUSE_FSif this unit test uses FS wrapper - please enable only if you really can't create the test without it, adding dependency to FS is not a good practice
Simple example
NOTE: I assume here that:
- test catalog was created
- test catalog was included properly If not - please read above!
Examplary executable can be added by creating test/CMakeLists.txt like that:
add_catch2_executable(
NAME
service-my_awesome_test
SRCS
test-MyAwesomeTest.cpp
LIBS
)
Which will create target:
catch2_service-my_awesome_test
This means you can build it and run with:
ninja catch2_service-my_awesome_test && catch2_service-my_awesome_test