Skip to content

Add GoogleTest support and an example GTest test

Riccardo Maria Bianchi requested to merge add-googletest-support into main

This MR adds support for the GoogleTest suite in the GeoModel CMake configuration.

It also adds an example GTest test and configures it so that CTest discovers it and runs all tests defined it it separately.

To do the above, in the CMake configuration we don't use the standard CMake add_test function to configure the test but we configure it with the GTest's own method:

include(GoogleTest)
gtest_discover_tests(test_db_functions)

For example, let's say that our test_db_functions.cpp source code defines two tests: CreateDB and PopulateDB.

If we use the standard CMake add_test function, CTest will only print one line of output for all tests together, with an overall final flag:

      Start 11: testDBFunctions
11/14 Test #11: testDBFunctions ....................   Passed    0.05 sec

Instead, if we use the GTest's own method, CTest will be able to see them as separate tests and we will get two lines of output, with a separate result for each of the two tests:

      Start 10: DatabaseTest.CreateDatabaseTest
10/15 Test #10: DatabaseTest.CreateDatabaseTest .....   Passed    0.00 sec
      Start 11: DatabaseTest.PopulateDatabaseTest
11/15 Test #11: DatabaseTest.PopulateDatabaseTest ...   Passed    0.03 sec

Cc: @tsulaia @boudreau @sroe

Merge request reports

Loading