Building and Running Unit Tests
Previous: Using the console
The project builds are set up using cmake
. Find the required version under
Set up your environment.
Unit tests are generally set up in each module in the test
folder, however to build and run them
the configuration and mocks provided under executables/unitTest
are required.
Configure and generate a project buildsystem for the unit test build:
cmake -DBUILD_UNIT_TESTS=ON -B cmake-build-unit-tests -S executables/unitTest
Different generators are also supported, for example Ninja:
cmake \
-G Ninja \
-DBUILD_UNIT_TESTS=ON \
-B cmake-build-unit-tests \
-S executable/unitTest
Build all tests or a specified target:
# all tests
cmake --build cmake-build-unit-tests -j
# specific target
cmake --build cmake-build-unit-tests -j --target <unit_test_target>
# example
cmake --build cmake-build-unit-tests -j --target estdTest
Find all available targets for the unit test build:
cmake --build cmake-build-unit-tests --target help
Prepare a clean build using the clean target:
cmake --build cmake-build-unit-tests -j --target clean
Run the tests:
ctest --test-dir cmake-build-unit-tests -j