I have followed the instructions at https://testthat.r-lib.org/ for adding unit tests to an R package using the testthat library.
The tests themselves run fine, but RStudio is yellow-squiggle underlining all the functions from both testthat and my package with the message no symbol named 'expect_true' in scope for example (example image below).
This is really annoying and I have a "no warnings" mindset when it comes to code so I would like to fix them properly without affecting "genuine" warnings in the tests.
I have I already tried:
.lintr file to the package root:linters: with_defaults(
object_usage_linter = NULL
)
exclusions: list("tests/testthat")
testthat and my package are in tests/testthat.R:library(testthat)
library(MyPackage)
test_check("MyPackage")
3 Adding export(is_valid_time) to the NAMESPACE file at the package root, which would not solve the testthat calls, but I thought might at least solve the calls into my package functions.
None of these changed the RStudio behaviour (I restarted RStudio to make sure it picked up these changes).
The answer here was to click Build->Load All (Ctrl-Shift-L) (or equivalently run devtools:load_all("path/to/my/project"), which loads the correct things into scope.