How to write unit tests for zzz.R file in R package

Viewed 208

I am currently developing an R package and used a zzz.R file to set an option value when the package is loaded and also to return a load message. The content of my zzz.R file is as follows:

.onLoad <- function(libname, pkgname) { 
  op <- options()
  op.mypackage <- list( 
    mypackage.small_neg_threshold = -1e-6
  )

  toset <- !(names(op.mypackage) %in% names(op))
  if (any(toset)) options(op.mypackage[toset])
}

.onAttach <- function(libname, pkgname) { 
  packageStartupMessage(
    "

  Hello World!!!

" 
  )
}

I wondering how one could write a test case in such that entire zzz.R file would be captured as being covered (after running something like devtools::test_coverage()

0 Answers
Related