VMF uses the Google Test framework for unit testing. A basic overview of the framework as well as example unit test are available here: Primer.
To run the existing VMF unit tests use the following commands (on windows, be sure to do this in the Developer Command Prompt for Visual Studio)
cd build
ctestOn windows, the unit tests may also be run within Visual Studio by building the RUN_TESTS target.
For additional output on any failed tests
ctest --output-on-failureFor additional output on all of the tests
ctest --VVTo test modules within the VMF repository, additional tests may be added to the existing /test/unittest/CMakeLists.txt.
Alternatively a new CMake file may be created. Keep in mind that the following three things are needed to run the Google Test framework:
- The test executable must be added to a
CMakeLists.txtfile. e.g.add_executable(exampleTest exampleTest.cpp)
- The
gtest_mainlibrary must be linked against said executabletarget_link_libraries(exampleTest PUBLIC gtest_main )
- The
GoogleTestCMake module components must be pulled in.include(GoogleTest) gtest_add_tests(TARGET exampleTest)