Dev:Doc/Tools/Tests/GTest

提供: wiki
< Dev:Doc‎ | Tools‎ | Tests
2018年6月29日 (金) 06:09時点におけるYamyam (トーク | 投稿記録)による版 (1版 をインポートしました)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先: 案内検索

GTest

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/BLI_path_util_test.cc'

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: https://code.google.com/p/googletest/w/list

See Blenders Automated Testing Project: http://developer.blender.org/tag/automated_testing