Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.22 KB

testing.md

File metadata and controls

45 lines (35 loc) · 1.22 KB

VMF Unit Tests

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.

Running the VMF Unit Tests

To run the existing VMF unit tests use the following commands

cd build
ctest

For additional output on any failed tests

ctest --output-on-failure

For additional output on all of the tests

ctest --VV

Adding new Unit Tests to CMake

To 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.txt file. e.g.
      add_executable(exampleTest exampleTest.cpp)
  • The gtest_main library must be linked against said executable
      target_link_libraries(exampleTest
          PUBLIC
              gtest_main
      )
  • The GoogleTest CMake module components must be pulled in.
      include(GoogleTest)
      gtest_add_tests(TARGET exampleTest)