GoogleTest provided with C/C++test CT can be integrated into a Bazel project that uses modules. Follow these steps to integrate it into your project:
Extract the contents of the
<INSTALL_DIR>/googletest/googletest.zip. package.It is recommended to extract the archive to
<INSTALL_DIR>/googletest. This guide assumes the GoogleTest sources are located there.In your Bazel project, add the following to the top-level MODULE.bazel file:
# if another version of googletest is already specified, then that one must be commented out bazel_dep(name = "googletest", version = "1.17.0") local_path_override( module_name = "googletest", path = "<INSTALL_DIR>/googletest", )
Notes:
- This procedure has been tested with Bazel 6, 7, and 8.
- The GoogleTest version provided with C/C++test CT is specified in
<INSTALL_DIR>/googletest/MODULE.bazel. If you encounter version mismatch errors, verify that the version specified in MODULE.bazel matches the version used in your project'sbazel_dep()statement. - GoogleTest 1.17.0 does not support Bazel 9+.