Bazel error No test targets were found, yet testing was requested
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
This Bazel error means your bazel test command resolved to zero actual test rules. Bazel is not saying tests failed; it is saying that, after expanding the target pattern and applying any filters, there was nothing of a test rule type left to run.
What Bazel Counts as a Test Target
Bazel only runs rules that are declared as test rules, such as:
- '
cc_test' - '
java_test' - '
py_test' - '
go_test' - language-specific wrappers that ultimately produce test targets
A cc_binary or py_library is not a test target, even if it contains test-like code.
So if you run:
and there are no matching *_test rules under that package path, Bazel expands the pattern, finds no tests, and throws this error.
The Most Common Causes
The error usually comes from one of these situations:
- the target pattern points at packages with no test rules
- the named target exists but is not a test rule
- a
test_suiteexpands to nothing - tag or size filters exclude all discovered tests
- the package path is wrong or outside the current workspace view
That is why the first task is always to inspect what Bazel thinks is available.
Use bazel query to See the Truth
A very effective debugging step is to ask Bazel to list test targets directly.
If this returns nothing, the error is expected: there are no test rules under that pattern.
If it returns test rules but bazel test still fails, then filters or target spelling are the next suspects.
Check the BUILD File
Here is a simple valid py_test example:
If your BUILD file only contains something like this:
then bazel test //path:math_lib will not work because math_lib is not a test rule.
Test Suites Can Also Be Empty
A test_suite is valid only if it actually expands to test targets.
If the tests list is empty, or points at rules that are not real tests, bazel test //path:all_tests can produce the same error.
This is especially common when someone refactors targets and forgets to update the suite.
Filters Can Accidentally Remove Everything
Sometimes Bazel does find test rules, but later filtering eliminates all of them.
Examples include:
- '
--test_tag_filters' - '
--build_tag_filters' - '
--test_size_filters' - platform or configuration constraints
A command such as:
will fail with this message if none of the discovered tests carry the integration tag.
That makes the error look like a BUILD-file issue when it is really a filtering issue.
Package and Workspace Scope Matter
Bazel target patterns are workspace-relative. If the package path is wrong, Bazel may be looking in the wrong place entirely.
Useful checks:
These help confirm that the package and targets you think exist are actually visible to Bazel under the current workspace.
A Practical Debugging Sequence
A reliable order of operations is:
- run
bazel query 'kind(".*_test", //your/pattern/...)' - open the relevant BUILD file
- confirm the target is a real test rule
- remove tag or size filters temporarily
- rerun
bazel testwith the simplest possible target pattern
This narrows the issue quickly without guesswork.
Common Pitfalls
A common mistake is running bazel test on a binary or library target and expecting Bazel to infer that it is a test.
Another issue is using a wide pattern such as //... and then filtering away everything with tags or sizes.
Developers also often forget that a test_suite can be syntactically present but semantically empty.
Finally, if bazel query returns no tests, do not keep tweaking flags. The BUILD graph itself is not exposing any runnable test targets for that pattern.
Summary
- The error means Bazel found zero runnable test targets after expansion and filtering.
- Verify actual test rules with
bazel query 'kind(".*_test", ...)'. - Make sure the target is a test rule, not a library or binary.
- Check
test_suitecontents and tag or size filters. - Start debugging with the simplest target pattern before adding filters.

