Integrating googletest framework
I have added the googletest framework (Tests/gtest) as well as a simple test example (Tests/BaseLib/Swap) in a similar way as it was done in OGS-5.
To write new tests simply add a source file containing TEST(Group, TestName)
-blocks into Tests/ or create a new subdirectory in Tests/ and it in the Tests/CMakeLists.txt via GET_SOURCE_FILES(TEST_SOURCES Subdirectory)
.
Run tests via make test
or ctest
:
$ make test
Running tests...
Test project /Users/bilke/ent/ogs6/build_gcc
Start 1: test-harness
1/5 Test #1: test-harness ..................... Passed 1.86 sec
Start 2: zlib-example
2/5 Test #2: zlib-example ..................... Passed 0.01 sec
Start 3: Base.SwapInt
3/5 Test #3: Base.SwapInt ..................... Passed 0.01 sec
Start 4: Base.SwapDouble
4/5 Test #4: Base.SwapDouble .................. Passed 0.01 sec
Start 5: Base.SwapString
5/5 Test #5: Base.SwapString .................. Passed 0.01 sec
100% tests passed, 0 tests failed out of 5
Total Test time (real) = 1.92 sec
Tests building is enabled by default but can be disabled with the CMake-Option OGS_BUILD_TESTS=OFF
.