简体   繁体   中英

How to implement Code coverage (gcov) with Bazel

I am starting to work with bazel, My current aim is to implement code coverage with bazel. Could you please share any examples or documentation for the same?

bazel coverage

will do the job. The coverage command line argument generates code coverage report for specified test targets

Example

  bazel coverage -s \                                         
    --instrument_test_targets \
    --experimental_cc_coverage \
    --combined_report=lcov \
    --coverage_report_generator=@bazel_tools//tools/test/CoverageOutputGenerator/java/com/google/devtools/coverageoutputgenerator:Main \
    //...

HTML Output:

  genhtml /home/vertexwahn/.cache/bazel/_bazel_vertexwahn/e74a825d0eb0c2db4b6f8afd819b274c/execroot/__main__/bazel-out/k8-fastbuild/testlogs/foo_test/coverage.dat --output-directory coverage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM