code-coverage - Lcov 不一致的覆盖范围

标签 code-coverage lcov

我开始使用 lcov大约一个月后。覆盖计数似乎不一致。第一次运行报告了大约 75% 的线路覆盖率,而第二次运行仅报告了 19%。两次运行都使用了一些测试套件。我在 lcov --remove 期间看到以下警告.有什么建议吗?

lcov: WARNING: negative counts found in tracefile all.info



这是需要担心的吗?

最佳答案

同知 issue在 GitHub 上报告了这里。

Replacing all counts of -1 in the output with 0 (e.g. with sed -i -e 's/,-1$/,0/g' <outputfile>) causes the warning to disappear from the lcov and genhtml output while still producing the correct coverage report.

More importantly (at least for me), submitting the file with the counts set to 0 instead of -1 to codecov.io results in the results being parsed correctly and the coverage information being available through codecov.io.



Codecov还处理这种值错误:
# Fix negative counts
$count = $2 < 0 ? 0 : $2;
if ($2 < 0)
{
  $negative = 1;
}

遵循一些其他修复:
  • Fix Undocumented Value
  • Remove fix for negative coverage counts
  • 关于code-coverage - Lcov 不一致的覆盖范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25585895/

    相关文章:

    c# - PostSharp 和 Visual Studio 代码覆盖率

    c++ - 有没有办法调用纯虚类的 "deleting destructor"?

    gcov - lcov 用于包含 gcda 文件的多个目录

    C++使用gcov和lcov问题?

    gcov - lcov 无法正常覆盖

    代码覆盖率——哪次运行覆盖了哪些代码?

    unit-testing - PHPUnit HTML 和 Clover 覆盖率报告因 codeCoverageIgnore 而不同

    python-3.x - 为什么 Python 3.8.3 的单元测试覆盖被禁用?

    java - 清除 Eclipse 中突出显示的覆盖范围

    phpunit - 无法使用 CodeCoverage 和 Composer 重新声明类错误