I am extremely new to Bazel and Gtest and have been trying to run the tests on a cpp file called "species_test".cpp. This is the main error that I keep getting:
Wills-iMac:species Will$ bazel test species_test --test_output=all
ERROR: Skipping 'species_test': no such target '//species:species_test': target 'species_test' not declared in package 'species' defined by /Users/Will/git/orville-regularwills/species/BUILD.bazel
ERROR: no such target '//species:species_test': target 'species_test' not declared in package 'species' defined by /Users/Will/git/orville-regularwills/species/BUILD.bazel
INFO: Elapsed time: 0.473s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)
FAILED: Build did NOT complete successfully (0 packages loaded)
I have two BUILD.bazel files:
this one is for the .cpp class implementation:
cc_library(
name="species",
srcs=glob(["*.cpp"]),
hdrs=glob(["*.h"]),
visibility=["//visibility:public"]
)
and this one is for the file for google test that has species_test.cpp:
cc_test(
name="species_test",
srcs=["species_test.cpp"],
copts=["-Iexternal/gtest/include"],
deps=[
"@gtest//::main",
"//species"
]
)
and here is my workspace 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",
)
I have no idea what the error is referring to and greatly appreciate anything that points me in the right direction or clears anything up.
question from:
https://stackoverflow.com/questions/65876390/bazel-and-gtest-error-target-not-declared-in-package 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…