masscalculator-core
|
Tests for the MassCalculator core codebase are created using the googletest
framework.
googletest
is added to the codebase as a third-party.
Every library under the $MASSCALCULATOR_SOURCE/libraries
folder has to contain a tests
subfolder which will contain its CMakeLists.txt
file, defining all the tests, and all the necessary source files.
First of all, CMake functions that support googlestest
have to be made available with:
Tests are defined using the CMake function add_executable
, just like any other executable. e.g.,
Link your test executable to the required libraries they are using, e.g.,
To use googletest
in a test executable simply call this CMake function after creating the executable with add_executable
:
The following is not necceserily needed, but this is what is used to add the tests to CTest
, gtest_add_tests
does this for you:
If the build was configured to build any of the test, you can call CTest from the build directory to run them.
This will use a regular expression to find all tests targets with the name that contains "DemoTestName". If you added that tag to the add_gest
calls, CTest will find the right tests for you.