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")
bar.R
test-foo.R
, source bar: source("bar.R")
RStudio Version 1.1.447, R version 3.4.4, Mac OS X 10_13_4
This appears to be due to a bug in testthat 2.0.0
. Adding a context("Name of test context")
to the top of each test file worked for me (tested using Ubuntu and Windows).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With