-
Notifications
You must be signed in to change notification settings - Fork 4
Description
https://devguide.ropensci.org/pkg_building.html#testing
To quote key relevant points from the guidelines:
All packages should have a test suite that covers major functionality of the package. The tests should also cover the behavior of the package in case of errors.
It is good practice to write unit tests for all functions, and all package code in general, ensuring key functionality is covered. Test coverage below 75% will likely require additional tests or explanation before being sent for review.
...
If your package interacts with web resources (web APIs and other sources of data on the web) you might find the HTTP testing in R book by Scott Chamberlain and Maëlle Salmon relevant. Packages helping with HTTP testing (corresponding HTTP clients):
...
- testthat has a function skip_on_cran() that you can use to not run tests on CRAN. We recommend using this on all functions that are API calls since they are quite likely to fail on CRAN. These tests should still run on continuous integration. Note that from testthat 3.1.2 skip_if_offline() automatically calls skip_on_cran(). More info on CRAN preparedness for API wrappers.
...
- Even if you use continuous integration, we recommend that you run tests locally prior to submitting your package (you might need to set Sys.setenv(NOT_CRAN="true")).