How to include all targets in bazel coverage

Viewed 179

How do I include non-test targets in bazel coverage? Currently I use the following bazel command to get code coverage:

bazel coverage \
  --instrument_test_targets \
  --experimental_cc_coverage \
  --combined_report=lcov \
  //... --test_arg=--logtostderr

The project is written in C++. The command works fine. However, the output lcov trace file only includes the files that have coverage. If a C file does not have a test, it is not in the lcov trace file.

Does bazel coverage only executes the test targets? Is there a way to include all targets (the non-test targets)? So that even if a file has no test, I can still see it in the report (the report will show zero coverage). The intention for this is that if someone adds new files and doesn't write unit test, the file can be shown in coverage report.

1 Answers

Can you reproduce using --incompatible_cc_coverage?

Related