MSCL uses a suite of unit tests to ensure library stability and correctness. The tests are built using the Boost Test Framework and the Turtle mock library.
- Boost: Specifically the
unit_test_frameworkcomponent. - Turtle: A C++ mock object library based on Boost.
To enable building the tests, use the following CMake option:
| Option | Description | Default |
|---|---|---|
MSCL_BUILD_TESTS |
Whether to build the unit test suite. | OFF |
| Option | Description | Default |
|---|---|---|
Turtle_ROOT |
Manual path to search for Turtle headers. | (Empty) |
Turtle_REQUESTED_VERSION |
Version of Turtle to download if not found. | 2.0.0 |
Building documentation requires the Boost testing framework and Turtle. MSCL
is capable of downloading Turtle if it does not already exist on the system. The
options listed above are optional to allow MSCL to find Turtle before
downloading it. The Boost testing framework will be downloaded using vcpkg if
MSCL_USE_VCPKG and MSCL_DOWNLOAD_BOOST are ON otherwise, it needs to
already exist on the system.
-
Enable tests in your CMake configuration:
cmake -S . -B build -DMSCL_BUILD_TESTS:BOOL=ON
cmake -S . -B build -DCMAKE_BUILD_TYPE:STRING=Debug -DMSCL_BUILD_TESTS:BOOL=ON -
Build the tests:
cmake --build build --config Debug --target MSCL-Tests --parallel $env:NUMBER_OF_PROCESSORS
cmake --build build --target MSCL-Tests --parallel $(nproc) -
Run the tests:
cd build ctest -C DebugAlternatively, you can run the test executable directly:
./build/tests/Debug/MSCL-Tests.exe
./build/Debug/tests/MSCL-Tests
The tests are configured to output results in JUNIT format to
mscl_test_results.xml by default when run via the build system, which is
useful for CI/CD integration.