Skip to contents

In a test_case_plan() declaration, add a named literal fixtures = list(...) to a case. Each fixture has a literal source and md5, and may specify required = FALSE. Use a file path relative to the case's suite directory (tests/testthat or longtests/testthat), or an HTTPS URL. Use forward slashes and keep local fixtures inside the suite. Use ordinary files. Local fixture declarations should not point to special files or links outside the suite directory. Add fs to the consumer package's Suggests when declaring fixtures. Compute the checksum with tools::md5sum().

Value

In each generated test, fixture_paths is a named character vector with one path or NA_character_ per fixture.

Details

The generated test provides a named character vector fixture_paths to the case setup and body. Unavailable optional fixtures have NA_character_ paths. A required local fixture that is absent or has changed fails the generated test. Standard testthat runs do not resolve remote fixtures and skip cases that require them.

Use run_test_plan() or run_test_case() to check all declared fixtures before a case starts. The runners check local files and look for remote files in BiocFileCache. Enable download_fixtures explicitly to fill the cache. Only downloads that match the declared checksum are cached. Keep a custom cache outside the package source tree. Planning and generation do not access the files or the network.