Skip to main content
In this section, you learn what the bazel test command does and how you control test behavior in your Bazel projects.

The bazel test command

The bazel test command is used to execute all testable targets, and report whether each test passes or fails. For example, to run all tests in the repository, use a target pattern:

Controlling test execution

Control over the test process is largely left to your Bazel command-line flags. This includes things like:
  • --test_args - arguments to forward to the test runner’s CLI.
  • --test_env - which environment variables should be included in the test’s inputs and cache key.
  • --test_output
    • --test_output=streamed - useful to say, “stream the log”, so it’s similar to watching the test runner CLI run.
    • --test_output=errors - typical to get Bazel to print the test failures to stdout, otherwise you can only get them from the log in bazel-testlogs.