I am developing an R app and came up with a workaround to integrate testthat in it (it usually requires your project to be a package) by adding a DESCRIPTION
file to the project root.
I got this method from a colleague who managed to get it to work like this.
The problem is, when I try to test anything (even empty test files), I get this error:
Error in x[[method]](...) : attempt to apply non-function
Calls: <Anonymous> ... <Anonymous> -> o_apply -> lapply -> FUN -> <Anonymous>
Execution halted
What I know is that this appears only on macOS. My colleague can still run this app without problems on Windows.
What's the deal with it?
The MCVE for reproducing this error would be:
create a minimum
DESCRIPTION
file with content:Package: testpckg
add testthat to your project:
usethis::use_testthat() usethis::use_test("foo")
- create empty file
bar.R
- in
test-foo.R
, source bar:source("bar.R")
RStudio Version 1.1.447, R version 3.4.4, Mac OS X 10_13_4
2.0.1
is working fine withusethis::use_testthat()
andusethis::use_test("foo")
butcontext("test-foo")
instead ofsource("bar.R")
` – Unguent