Skip to content
Zhian N. Kamvar edited this page Jul 8, 2015 · 3 revisions

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.

Test without CRAN

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

Testing in Windows

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.