将测试包含在二进制R包中 [英] Include tests in binary R package
问题描述
我正在使用testthat
为我的R包编写单元测试.我见过一些软件包作者(例如Rcpp
和ggplot2
的软件包作者)使用二进制文件分发其单元测试.
但是,当我使用RStudio(0.98.1102)和<c3>(1.7.0)构建软件包时,tests
文件夹未包含在zip文件中.我是否必须手动添加文件夹,还是可以通过设置某些选项来自动完成此文件夹?
I am using testthat
to write unit tests for my R packages. I have seen a few package authors (like those from Rcpp
and ggplot2
) distributing their unit tests with the binary files.
However, when I build my packages with RStudio (0.98.1102) and devtools
(1.7.0) the tests
folder is not included in the zip file. Do I have to add the folder manually or is it possible to get this done automatically by setting some option?
顺便说一句:我在使用R v3.1.2和RTools v3.1.0.1942的Win7机器上.
BTW: I am on a Win7 machine using R v3.1.2 and RTools v3.1.0.1942.
推荐答案
哈!知道了.
在testthat
的github页面上找到了信息(在最底部).
https://github.com/hadley/testthat
Ha! Got it.
Found the information on the github page of testthat
(it's at the very bottom).
https://github.com/hadley/testthat
这种新结构的优点在于,用户可以控制是否使用R CMD install的--install-tests参数或install.packages的INSTALL_opts ="--install-tests"参数来安装测试. ().我不确定为什么您不想安装测试,但是现在您可以选择了.
The advantage of this new structure is that the user has control over whether or not tests are installed using the --install-tests parameter to R CMD install, or INSTALL_opts = "--install-tests" argument to install.packages(). I'm not sure why you wouldn't want to install the tests, but now you have the option.
使用测试构建二进制软件包的命令是
The command to build the binary package WITH the tests is
devtools::build(binary=TRUE,args=c("--preclean","--install-tests"))
这篇关于将测试包含在二进制R包中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!