Bazel Rules Testing

rules_testing is a collection of utilities, libraries, and frameworks to make testing Starlark and Bazel rules easy and pleasant.

version |version|

Installation

To use rules_testing, you need to modify WORKSPACE or MODULE.bazel to depend on rules_testing. We recommend using bzlmod because it’s simpler.

For bzlmod, add this to your MODULE.bazel:

bazel_dep(name = "rules_testing", version = "<VERSION>", dev_dependency=True)

See the GitHub releases page for available versions.

For WORKSPACE, see the GitHub releases page for the necessary config to copy and paste.

Analysis tests

Analysis testing means testing something during the analysis phase of Bazel execution – this is when rule logic is run.

See Analysis tests for how to write analysis tests.

Fluent asserts

Included in rules_testing is a fluent, truth-style asserts library.

See Truth docs for how to use it.