From Blender Developer Wiki
Jump to: navigation, search


GTest is a C++ testing framework which can be used to test C/C++ code in Blender. It needs to be enabled at build-time, and creates tests (in the form of executables) which are run to perform the tests.

Tests are located in blenders source directory 'tests/gtests'

Enable the `WITH_GTESTS` CMake build option and execute the tests from the build directory 'bin/tests/'

Example use

The tests for Blender's path utilities: 'source/blender/blenlib/intern/path_util.c'

Test file located in: 'tests/gtests/blenlib/'

The test can be executed from the build directory: './bin/tests/BLI_path_util_test'

And produces output, for example:

[==========] Running 3 tests from 1 test case.
[----------] Global test environment set-up.
[----------] 3 tests from path_util
[ RUN      ] path_util.PathUtilClean
[       OK ] path_util.PathUtilClean (0 ms)
[ RUN      ] path_util.PathUtilFrame
[       OK ] path_util.PathUtilFrame (0 ms)
[ RUN      ] path_util.PathUtilSplitDirfile
[       OK ] path_util.PathUtilSplitDirfile (0 ms)
[----------] 3 tests from path_util (0 ms total)

[----------] Global test environment tear-down
[==========] 3 tests from 1 test case ran. (0 ms total)
[  PASSED  ] 3 tests.

Further Reading

For information on the GTest framework its self, see:

See Blenders Automated Testing Project: