Test Explorer + Coverage for Bazel tests in VS Code.
Uses bazel query, bazel test, and bazel coverage, integrated with the VS Code Testing API.
- Show tests in the Testing view (query + run).
- CodeLens, gutter markers, diagnostics.
- Coverage reports in the Testing UI.
- Test Details panel (incl. Coverage tab).
- Advanced Bazel test settings.
- Install the extension from the VS Code Marketplace.
- Ensure Bazel is installed.
- Open Testing.
- Run tests or Coverage from the UI.
bazelTestExplorer.testTypes- e.g.cc_test,rust_test,py_test,go_test.bazelTestExplorer.queryPaths-//...or specific paths.bazelTestExplorer.testArgs- extra flags forbazel test.bazelTestExplorer.coverageArgs- extra flags forbazel coverage.
To get a working coverage (with C/C++) is sometimes annoying. Here some tipps:
- MODULE.bazel.:
- use
bazel_dep(name = "toolchains_llvm", version = "1.6.0")andllvm_version = "19.1.0"or newer.
- use
- .bazelrc:
--combined_report=lcovcreates a centralbazel-out/_coverage/_coverage_report.datfor easier coverage aggregation.--instrumentation_filter=.*can be slow in large repositories. Adjust this filter in settings to match your source paths (e.g.--instrumentation_filter="//src/...").- set
coverage --experimental_use_llvm_covmapandcoverage --experimental_generate_llvm_lcov - on macOS set
coverage --copt=-fcoverage-compilation-dir=.
- System:
c++filt/rustfiltshould be available inPATHfor demangled names in coverage.
Coverage should be working in terminal!! If not the extension can not fix this.
MIT License
