I want to create a Bazel C++ project with gtest for unit tests.
What is the minimal setup?
(I only have Bazel installed on my computer and I am running under Linux)
Building CMake projectsIn BUILD. bazel , we instantiate a cmake rule which behaves similarly to a cc_library, which can then be used in a C++ rule (cc_binary in this case).
Google Test (also known as gtest) is a unit testing library for the C++ programming language, based on the xUnit architecture. The library is released under the BSD 3-clause license.
This is even easier now that googletest provides a BUILD file:
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") git_repository( name = "gtest", remote = "https://github.com/google/googletest", branch = "v1.10.x", )
cc_test ( name = "hello_test", srcs = [ "hello_test.cc", ], deps = [ "@gtest//:gtest", "@gtest//:gtest_main" # Only if hello_test.cc has no main() ], )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With