-
-
Notifications
You must be signed in to change notification settings - Fork 26
Testing in poppr
Testing in poppr is achieved through the package testthat. If you contribute to poppr, you should write tests for your contributions especially if these contributions have analytical output (i.e. a genetic distance or differentiation test). The tests live in the folder tests/testthat
. These tests are run during R CMD check, so to avoid getting grief from the maintainers, make sure your tests run in under a second.
Testthat added a function at some point called skip_on_cran()
. This allows us to run tests that might take a little longer. A good way to see how the tests behave on and off of CRAN is to use the --install-tests
options for R CMD INSTALL
(This can be set with Rstudio in the build tools). Once you install the package this way you can run the following:
library("poppr")
library("testthat")
test_package("poppr") # How CRAN sees things
Sys.setenv(NOT_CRAN = "true") # This is the environmental variable testthat looks for
test_package("poppr") # ALL THE TESTS
If you use a *nix system, make sure your tests pass on Windows machines. An easy way to do this is to use the function build_win()
from the devtools package.