BergelsonLab / BergelsonLab/blabr
compartmentalize test code
- Dominant language
- R
- Stars
- 1
- Forks
- 3
- PR merge metrics
- No merged PRs in 30d
Description
- Move `R/test-helpers.R` to `testthat/helpers.R` so that packages only needed for testing aren't referred to in the package's code. I put it under `R/` because testthat at some point said that using `testthat/helpers*.R` was no longer recommended (indirect evidence [here](https://blog.r-hub.io/2020/11/18/testthat-utility-belt/#:~:text=R%20scripts%20under%20tests%2Ftestthat%2F%20whose%20name%20start%20with%20helper,as%20recommended%20in%20testthat%20docs.)). Apparently, referring to functions from packages that aren't your package's "Import" dependencies isn't a problem, that's what "Suggests" are for. Nevertheless, to me, it makes so much more sense to have testing code separate from the package's code.
- Remove `library` calls from all test files, switch to qualified function calls. I don't know why but at some point I decided it was ok to put `library()` calls inside tests. As the result, tests will pass even if there is an unqualified call to, say, mutate, in the package's main code that is being tested. I didn't know why I expected it to work otherwise but I am not alone - see [this SO questions](https://stackoverflow.com/questions/75822979/why-do-packages-loaded-inside-test-that-provide-their-methods-outside-of-te)
Contributor guide
Assessment
This issue has not been assessed yet.