-
Testing is strongly encouraged for all DataSHIELD packages. Recommended framework: testthat.
-
All exported functions are expected to have associated unit tests. Tests should cover: expected inputs, invalid inputs, edge cases, disclosure control behaviour, error handling.
-
Minimum test coverage of 75%. Coverage tools: covr GitHub Actions coverage workflows.
-
When a package is intended for submission to CRAN, consider using skip_on_cran() for tests that require network access, rely on external services, or are particularly computationally intensive.
-
CI requirements
- all tests must pass in CI,
- no PR merged with failing checks.
-
Testing data sets should follow disclosure Control and Security Policy
-
Recommended tests
- Argument Tests : Verify that functions correctly validate input arguments and return appropriate errors for invalid or missing inputs.
- Data Checking Tests : Verify that functions correctly handle different data types, structures, missing values, and other data-related conditions before analysis.
- Disclosure Tests : Verify that statistical disclosure protection is enforced by preventing the release of potentially disclosive results.
- Disclosure Control Tests:Verify that disclosure control parameters (e.g. disclosure thresholds and privacy settings) are correctly applied during analysis.
- Exception Tests:Verify that functions correctly throw expected exceptions or error conditions when invalid operations are attempted.
- Mathematical Correctness Tests :Verify that statistical calculations are mathematically correct by comparing results with expected values or equivalent native R implementations.
- Performance Tests :Verify that execution time and computational performance remain within acceptable limits and detect performance regressions.
- Smoke Tests:Perform a basic end-to-end check that a function executes successfully under normal conditions without verifying every aspect of the output.