加载testthat包仅用于测试,但不要求依赖 [英] Loading the testthat package only for tests but not requiring in dependencies

查看:134
本文介绍了加载testthat包仅用于测试,但不要求依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

构建软件包会导致以下警告:

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.

包目录有一个名为的文件夹 ,文件test-all.R:

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

library(testthat)
library(bootLR)

test_package("bootLR")

然后一个子文件夹 testthat 其中包含两个保存各种测试的文件。

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

错误消息可能告诉我,我没有在DESCRIPTION文件中声明testthat,但是我不想要最终用户的安装,我相信将test-all.R文件中的库(testthat)语句放在testthat手册。

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.

任何方式,或者我必须以正确的方式添加它(强制使用安装testthat)?

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

编辑:我想添加到建议:可能是最好的方法吗?

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

推荐答案

也许建议? 每个Hadley

这篇关于加载testthat包仅用于测试,但不要求依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆