bazelbuild / bazelbuild/rules_android
android_local_test coverage reports only synthetic baseline data
- Dominant language
- Java
- Stars
- 203
- Forks
- 95
- PR merge metrics
- No merged PRs in 30d
Description
Running `bazel coverage` on a Starlark `android_local_test` succeeds, but no execution coverage is collected.
I reproduced this on current `main` at `1d4cc58` with Bazel `9.0.0rc3`:
```sh
bazel coverage --combined_report=lcov --instrument_test_targets \
//test/rules/android_local_test/java/com/starlark_resources:no_deps_with_resources
```
The test passes, but its per-test `coverage.dat` is empty. The combined report contains only the synthetic baseline record:
```text
SF:test/rules/android_local_test/java/com/starlark_resources/SampleTest.java
FNF:0
FNH:0
LH:0
LF:0
end_of_record
```
`android_local_test` returns `InstrumentedFilesInfo`, but it does not define the implicit `_lcov_merger` dependency required for Bazel test rules. Bazel therefore runs the test with JaCoCo instrumentation, then `collect_coverage.sh` sees that `LCOV_MERGER` is unset and exits without processing the intermediate coverage data.
Bazel documents the required test rule setup here:
https://bazel.build/extending/rules#test-rules
Adding the coverage merger dependency to `android_local_test` produces line and function coverage in both the per-test and combined LCOV reports.
This is related to #558, but that issue covers broader extensibility for alternative coverage tools. This issue is about the default Bazel coverage path producing no execution data.
Contributor guide
Research direction
Start with the Starlark android_local_test rule and the test target //test/rules/android_local_test/java/com/starlark_resources:no_deps_with_resources. Trace how InstrumentedFilesInfo and the implicit _lcov_merger dependency are configured, then inspect collect_coverage.sh behavior when LCOV_MERGER is unset. Done means per-test coverage.dat and the combined LCOV report contain execution line and function coverage.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, java
- Domain
- mobile-dev, testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100