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:

  1. 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.

  2. 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: