简体   繁体   English

如何使用介子在 C++ 中执行代码覆盖?

[英]How to perform code coverage in C++ using meson?

I'm using meson and ninja as build system in my C++ project and I've configured catch2 as testing framework.我在我的 C++ 项目中使用 meson 和 ninja 作为构建系统,并且我已经将 catch2 配置为测试框架。 I was wondering how to perform code coverage with the tests that I've written.我想知道如何使用我编写的测试执行代码覆盖率。 I read this page, https://mesonbuild.com/Unit-tests.html but seems pretty unclear to me, can anybody help?我读了这个页面, https://mesonbuild.com/Unit-tests.html但对我来说似乎很不清楚,有人可以帮忙吗?

You should use one of coverage related targets: coverage-text , coverage-html , coverage-xml as described here .您应该使用覆盖相关目标之一: coverage-textcoverage-htmlcoverage-xml ,如here所述。 Or just coverage that tries all of these if possible:或者如果可能的话,只是尝试所有这些的覆盖范围

$ ninja coverage -C builddir

Results are written to ./builddir/meson-logs directory.结果写入./builddir/meson-logs目录。

Note that to produce html coverage reports you need lcov and genhtml binaries which are installed by lcov package.请注意,生成HTML覆盖报告您需要LCOV和由LCOV包安装GENHTML二进制文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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