Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test coverage using covr #431

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

Test coverage using covr #431

wants to merge 14 commits into from

Conversation

radbasa
Copy link
Contributor

@radbasa radbasa commented Jan 25, 2023

Changes

Two functions.

  • covr_r()
  • covr_report()

Requires Appsilon/covr@klmr-box-support

Take Note

Need some advice how to add this to the documentation

With box an exported variable and a module can have the same name. For example,

# example_name.R

#' @export
example_name <- "example string"      # variable
# test-example_name.R
box::use(
  app/example_name[example_name]
)

testthat("", {
  example_name
})

With testthat this is not a problem. But, this will throw a test fail inside covr. Inside a covr run, the call to example_name returns the box module, not the variable object. A solution is to use aliases in the unit test:

# test-example_name.R
box::use(
  app/example_name[en = example_name]
)

testthat("", {
  en
})

Closes #99

How to use

Inside a rhino app

  1. Remove existing installed covr package.
  2. Install Appsilon version of covr, devtools::install_github("Appsilon/covr@klmr-box-support") or remotes::install_github("Appsilon/covr@klmr-box-support")
  3. rhino::covr_r() to run a coverage test
  4. rhino::covr_report() to produce an HTML report

@radbasa radbasa added the type: feature Major new functionality label Jan 25, 2023
@radbasa radbasa self-assigned this Jan 25, 2023
@radbasa radbasa changed the title covr support Test coverage using covr Jan 25, 2023
@codecov-commenter
Copy link

codecov-commenter commented Jan 25, 2023

Codecov Report

Merging #431 (d2daa72) into main (6696e81) will decrease coverage by 0.69%.
The diff coverage is 0.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##             main     #431      +/-   ##
==========================================
- Coverage   11.90%   11.21%   -0.69%     
==========================================
  Files           8        8              
  Lines         294      312      +18     
==========================================
  Hits           35       35              
- Misses        259      277      +18     
Impacted Files Coverage Δ
R/tools.R 0.00% <0.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@jakubnowicki jakubnowicki marked this pull request as draft January 25, 2023 07:49
@jakubnowicki
Copy link
Member

Since this PR depends on the change done to covr, we need to wait for it to be accepted and included in CRAN release.

DESCRIPTION Outdated Show resolved Hide resolved
@radbasa
Copy link
Contributor Author

radbasa commented Jan 25, 2023

Added parameters to rhino::covr_r()

#' @param test_files Character vector of test files with code to test the functions. Defaults to
#'   all test files in `tests/testthat` with the `test-<name>.R` filename pattern.
#' @param line_exclusions passed to `covr::file_coverage`
#' @param function_exclusions passed to `covr::file_coverage`

@radbasa
Copy link
Contributor Author

radbasa commented Feb 8, 2024

@Johan-rosa Any comments on the covr-related functions? Message in private if necessary.

@Johan-rosa
Copy link
Member

@Johan-rosa Any comments on the covr-related functions? Message in private if necessary.

We're using these changes and everything is working as expected. Great job!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature Major new functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Coverage report for test_r()
4 participants