Clone this repo:
  1. dff02aa Add tool to automate bazel/robolectric.bzl updates (#143) by Ben Lee · 2 weeks ago upstream/master
  2. 988ffbb Update dependency rules_python to v0.40.0 (#148) by renovate[bot] · 2 weeks ago
  3. e841e3b Update dependency buildifier_prebuilt to v8 (#149) by renovate[bot] · 2 weeks ago
  4. 558fbd2 Update dependency bazel to v9.1.1 (#144) by renovate[bot] · 2 weeks ago
  5. f022003 Enable renovate (#142) by Ben Lee · 2 weeks ago

robolectric-bazel

This project provides build rules for integrating Robolectric into Bazel projects.

Releases


Installation

Follow instructions in the release notes from the release you use: https://github.com/robolectric/robolectric-bazel/releases

Usage

In your android_local_test targets in the BUILD files, depend on the Robolectric targets @maven//:org_robolectric_robolectric and @robolectric//bazel:android-all:

android_local_test(
    name = "greeter_activity_test",
    srcs = ["GreeterTest.java"],
    manifest = "TestManifest.xml",
    test_class = "com.example.bazel.GreeterTest",
    deps = [
        ":greeter_activity",
        "@maven//:org_robolectric_robolectric",
        "@robolectric//bazel:android-all",
    ],
)

Updating Android Versions

update-versions.py walks org.robolectric:android-all-instrumented on Maven Central and rewrites bazel/robolectric.bzl in place: it bumps the version and sha256 of any Android API group that has a newer release, and inserts new entries for any numeric API newer than the highest one currently listed.

./update-versions.py            # apply updates
./update-versions.py --dry-run  # preview without writing

Publishing Releases

A new release can be published by just pushing a tag.

Once the tag is pushed, GitHub Actions will build, test, and publish a release to both GitHub releases and the BCR.

Example:

git tag 4.11.1
git push origin 4.11.1