~aleteoryx/muditaos

ref: sign_test muditaos/doc/adding_unittests.md -rw-r--r-- 1.0 KiB
a217eeb3 — Dawid Wojtas [BH-2024] Fix lack of alarm directory after updating software 1 year, 5 months ago

#Adding Unit Test

#Unit test framework

For writing test we are using catch2. There are few test written in gtest but we focus on using catch2

#adding unit test

In CMakeLists.txt use add_catch2_executable function for tests based on catch2. If you wrote your test in gtest use add_gtest_executable function. Both functions are defined in test/CMakeLists.txt and there described parameters.

Each binary has it's own section, and in section we each test in separate line, each test name have to end with;

#checking what tests are run

On our CI, we check what tests are available in binaries and if they where run. If some tests are not run, job called "Check run unit tests" will fail, this check is not required for PR to pass, it is just indicator that some tests are not working.

#make check

This will run all defined tests, even disabled ones, what is useful for unit test debugging. This way is not used on CI.

cd build-purephone-linux-Debug
make check