Skip to content

Files

Latest commit

 

History

History
48 lines (36 loc) · 1.41 KB

testing.md

File metadata and controls

48 lines (36 loc) · 1.41 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 (on windows, be sure to do this in the Developer Command Prompt for Visual Studio)

cd build
ctest

On 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-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)