bazel_bats 0.40.0Latest published <1h ago
MODULE.bazel
bazel_dep(name = "bazel_bats", version = "0.40.0")
README

Publish on Bazel Central Registry Publish to my Bazel registry Tag and Release Test

bazel-bats: bazel test rules for the BATS testing framework (bats-core)

Usage

MODULE.bazel (a.k.a. bzlmod)

bazel_dep(name = "bazel_bats", version = "0.36.4") # Choose version here.

Workspace

Support for WORKSPACE was removed starting from bazel-bats 0.35.0. If you must use WORKSPACE, refer to earlier releases. Please acknowledge that earlier releases are not supported.

Supported bazel versions

bazel-bats is developed against bazel 9.2.0 (see .bazelversion), and every change is tested on CI against the latest release of both supported major versions: bazel 8 and bazel 9.

Code changes

In your BUILD.bazel file add the following:

load("@bazel_bats//:rules.bzl", "bats_test")

bats_test(
  name = "hello_world_test",
  srcs = ["hello_world.bats"],
)

If your test would like to make use of the bats-assert extension (assert_success, assert_failure, assert_output, etc), simply add uses_bats_assert = True to your bats_test() target. This still requires adding the appropriate load statements in your test file.

Examples

This repository is an example of a repo with BATS tests. If you have bazel installed, you can try it out as follows:

git clone https://github.com/filmil/bazel-bats.git
cd bazel-bats
bazel test //...

Feel free to take a look at the WORKSPACE file to see how your workspace file should look like and at tests/BUILD.bazel to see a sample build file.

To run the integration tests, change to the integration/ directory and run,

cd integration
bazel test //...

About

bazel-bats: bazel test rules for the BATS testing framework (based on bats-core)

@filmil/bazel-bats@filmil
Homepage
12stars
1:05 AM (7 minutes ago)
@filmil#10529 bazel_bats@0.40.0 (#10529)

Languages

Shell18%

Maintainers

@filmil

Versions

0.40.0 +5d2026-09-13
0.39.0 +2h2026-09-07
0.38.42 +4.5mo2026-09-07
0.38.23 +1d73% 82026-04-24
0.37.1 +3.3mo2026-04-23
0.38.9 +3.2mo2026-01-14
0.37.0 +20d2025-10-09
0.36.4 +6.3mo2025-09-18
0.35.027% 32025-03-13