However, this did not match codecov. I got 56.7 on travis but codecov shows 46.16. Am I using the wrong API? Hm, looks like percent_coverage does not include C++ files? I also tried by='line' but it didn't help,
@jpritikin That is strange that the estimates are so different. I'm not sure exactly what could be causing that.
Based on the arguments to tally_coverage(), which is called by percent_coverage(), I think the default behavior is by "line".
args(covr::tally_coverage)
## function (x, by = c("line", "expression"))
## NULL
What do you get when you set by = "expression"?
For my package, I get very similar estimates for line and expression, but the Codecov estimate of 83.74% is closer to the default line coverage reported by covr when run on my local machine.
Also, a general note on forums: it is best practice to link to any other forums where you previously asked the question. The first thing I did after reading your question was to go to the GitHub Issues for covr, where I found your question and Jim's response:
codecov is reporting coverage per line, covr is reporting coverage per expression. See ?tally_coverage .
@jimhester Based on tally_coverage(), it appears that covr also reports line coverage by default. Could you please elaborate on your explanation? Thanks!