Loading the testthat package only for tests but not requiring in dependencies

萝らか妹 提交于 2019-12-21 07:56:02

问题


Building a package results in the following warning:

* checking for unstated dependencies in tests ... WARNING
‘library’ or ‘require’ call not declared from: ‘testthat’
* checking tests ...
  Running ‘test-all.R’
 OK
* checking PDF version of manual ... OK
WARNING: There was 1 warning.

The package directory has a folder called tests, with a file test-all.R:

library(testthat)
library(bootLR)

test_package("bootLR")

Then a subfolder testthat with two files in it that hold the various tests.

The error message is likely telling me that I have not declared testthat in the DESCRIPTION file, but I don't want to require its installation by end-users, and I believe that putting the library(testthat) statement in the test-all.R file comes from the testthat manual.

Any way around this, or do I have to add it in the proper way (that forces uses to install testthat)?

Edit: I guess adding it to Suggests: might be the best way to do this?


回答1:


Maybe suggests? As per Hadley.



来源:https://stackoverflow.com/questions/21380288/loading-the-testthat-package-only-for-tests-but-not-requiring-in-dependencies

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!