Skip to content

Commit c8cd62e

Browse files
committed
Describe how to use test data files
1 parent 5b5a899 commit c8cd62e

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

R-packages/covidcast/DEVELOP.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,23 @@ that the changes look correct, then press Validate.
4646
Once you've validated all changes, press Quit and you will be able to commit the
4747
changed images and run the tests successfully.
4848

49+
### Using data files in tests
50+
51+
Unit tests should not depend on being able to load data from the COVIDcast API,
52+
since that data is subject to change. It is preferable to either use toy
53+
examples or to store static datasets to be loaded and used.
54+
55+
Small static datasets can be kept in `tests/testthat/data/` in RDS form (using
56+
`saveRDS` and `loadRDS`). The `testthat::test_path` function locates files
57+
relative to the `tests/testthat/` directory regardless of your current working
58+
directory, so for example you can use
59+
60+
```r
61+
foo <- readRDS(test_path("data/foo.rds"))
62+
```
63+
64+
to load `tests/testthat/data/foo.rds`.
65+
4966
## Documentation
5067

5168
We use

0 commit comments

Comments
 (0)