[R-pkg-devel] Is using global assignment in package tests allowed?

James Pustejovsky jepu@to @end|ng |rom gm@||@com
Thu Jan 27 15:55:49 CET 2022


Hello,

I'm writing unit tests using testthat for a package that we want to submit
to CRAN. Because of some aspect of how testthat works (which is beyond my
ken), I have only been able to get my tests to work by using global
assignment (<<-) to create some objects on which the tests are then run.
However, per CRAN policy: "Packages should not modify the global
environment (user’s workspace)."

Does anyone know whether this policy applies to all code within the
package, including unit tests? Or does it apply just to the code and
functions in /R?
Or to all code that is executed as part of checking the package (i.e., code
that is never run can use <<-)?

James

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list