android_local_test coverage reports only synthetic baseline data

Open
#560 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
72/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
android, java

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.

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:

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:

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.

Dominant language
Java
Stars
203
Forks
95
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_android

All issues in bazelbuild/rules_android

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.