我正在使用该testthat包为我的R包编写测试.我已按照http://r-pkgs.had.co.nz/tests.html上的说明进行操作(我相信).我用了
devtools::use_testthat()
Run Code Online (Sandbox Code Playgroud)
设置测试骨架.我已经创建了一个测试文件,tests/testthat文件名以test.当我devtools::test()在RStudio中运行或按Ctrl + Shift + T时,测试运行成功,但是当我运行R CMD check或Ctrl + Shift + E时,testthat找不到我的包.我收到了错误
> library(testthat)
>
> test_check("foo")
Loading required package: foo
Error in loadNamespace(name) : there is no package called 'foo'
Calls: test_check ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
In addition: Warning message:
In library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called 'foo'
Execution halted …Run Code Online (Sandbox Code Playgroud)