Questions tagged [covr]

Covr is test coverage reports for R. It records whether or not each line of code in a package is executed by the package’s tests.

13 questions
9
votes
1 answer

covr shows 0% of coverage while all tests with testthat pass

I have built a package with unit tests for most of the functions. The package has a standard structure: package: - R/ - file1.R - file2.R - ... - tests/ - testthat/ - tests_for_file1.R - tests_for_file2.R - ... …
jjankowiak
  • 3,010
  • 6
  • 28
  • 45
6
votes
1 answer

covr::package_coverage reports "No such file or directory"

I'm trying to see the code coverage of sumbose/iRF, so I did a git clone, started an R session inside of the directory, and > library(covr) > package_coverage() Error in file(con, "r") : cannot open the connection In addition: Warning messages: 1:…
nalzok
  • 14,965
  • 21
  • 72
  • 139
5
votes
0 answers

Launching an R background process/thread/etc. using current environment for unit testing

Since callr::r and callr::r_bg launch a background process in a clean environment, they do not fit neatly into unit test paradigms. An R unit test, run via testthat, loads the current development version of the package, but any background process…
jwimberley
  • 1,696
  • 11
  • 24
3
votes
1 answer

How to include tests with `skip_on_cran()` when calling `covr::package_coverage()`?

I have a few tests with skip_on_cran() in a package. They will be run locally when I use call devtools::test(). However, when calling covr::package_coverage(), it does not run these tests. How to include these tests in the call to…
sfcheung
  • 384
  • 2
  • 11
3
votes
0 answers

R: What is the working directory when executing covr?

I'm working on a project, where I load a json file. By default, I start the project at the root of the project, however when testing, the path changes. Therefore I included the following statement: if (grepl("testthat", getwd())) { template <-…
Ai4l2s
  • 525
  • 2
  • 9
3
votes
1 answer

Testthat and covr in one go

I would like to run tests for a package with testthat and compute code coverage with covr. Furthermore, the results from testthat should be saved in the JUnit XML format and the results from covr should be saved in the Cobertura format. The…
robertdj
  • 909
  • 1
  • 5
  • 10
2
votes
0 answers

R: why is covr::package_coverage() always throws me an error starting with Error: Failure in `/tmp/RtmptOqbpy/R_LIBS5b33c260c72/....`

I have a package that fails when i run covr::package_coverage(quiet = FALSE, clean = FALSE) or devtools::test_coverage with error message: Error: Failure in /tmp/RtmptOqbpy/R_LIBS5b33c260c72/package/package-tests/testthat.Rout.fail, anyone knows…
2
votes
2 answers

How to run covr::codecov() for a R package on Travis CI

I am trying to add Codecov support via library(covr) to my personal R package sesh. When I check locally the coverage tests run and report without incident: covr::package_coverage() sesh Coverage: 68.75% R/executeDevtoolDocument.R: 0.00% R/sesh.R:…
Nate
  • 10,361
  • 3
  • 33
  • 40
2
votes
1 answer

r testthat and covr use in a non-package library

I'd like to be able to use testthat and covr in a project that is not an r package. In fact does not use any third party services. Just a collection of plain-old-r source files I am struggling to find out if this is possible, and if so, the…
Hedgehog
  • 5,487
  • 4
  • 36
  • 43
1
vote
1 answer

How to create a Gitlab CI coverage badge for R

Being not familar with R myself, I'd like to create a badge to summarize the test coverage in Gitlab CI, using the covr package. The only way I found on the net was to use the gitlab function; however this seems to create an HTML page, which is not…
olebole
  • 521
  • 4
  • 17
1
vote
1 answer

Location of tests file in an R package

If I have tests/testhat/testhat.R, devtools::test() finds it and runs it, but covr:package_coverage() and R CMD check does not find it. If I have it as tests/testhat.R, devtools::test() doesn't find it but covr:package_coverage() and R CMD check…
mindlessgreen
  • 11,059
  • 16
  • 68
  • 113
0
votes
0 answers

How to provide threshold value of code coverage percentage to covr (R code coverage)

As a code coverage framework for R we are using covr (https://github.com/r-lib/covr). But I am unable to figure out where to provide the threshold value for minimum percent of the code that should be covered by the unit tests. Could you please…
subir
  • 310
  • 4
  • 13
0
votes
1 answer

R covr package does not work

I try to test code coverage of my R package. However, after Travis-CI build succeeds, it shows an error message that the R package I test does not contain covr package as follow: Error: ‘/home/travis/build/tzuliu/ooc’ does not contain a…
tzu
  • 183
  • 1
  • 9