You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Create helper functions (`load_*()`) to load or create
data for a FIMS model run, or run a FIMS model with
wrappers to save the fit output. These functions
check if the corresponding `.RDS` file exists; if not,
they generate the data or run the model and save
the output to an `.RDS` file. If the file exists,
they read and return the object from the `.RDS` file.
This ensures that test data is generated only once
and is available for subsequent test runs,
speeding up the process.
- Add error handling (e.g., `tryCatch()`) in data loading
functions to provide clearer messages when file
operations fail.
- Update README to document new helper functions
for loading data and running FIMS with wrappers.
- Rename `test-integration-caa-mle.R` to
`test-integration-caa-mle-without-wrappers.R` so it
can be filtered when running tests
(`devtools::test(filter = "xxx")`), speeding up
single-test execution.
- Update snapshot tests outputs from `.md` files
to `.csv` files.
- Replace nan with -999 in JSON files. Thanks to
@msupernaw for the fix to issue #940.
Copy file name to clipboardExpand all lines: tests/README.md
+4-9Lines changed: 4 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,13 +17,8 @@ Prepare the test data in the new file or in a separate file if you plan on reusi
17
17
- In-line test data: make the data directly in the new test file within the `setup` section.
18
18
- C++ reusable test data: create a fixture file, e.g., `tests/gtest/test_XXX_test_fixture.hpp`, to prepare reusable unit-test data, or create an integration file, e.g., `tests/gtest/integration/XXX.hpp`, to set up integration-test data for C++ tests.
19
19
- If you used a test fixture from GoogleTest to use the same data configuration for multiple tests, `TearDown()` can be used to clean up the test and then the test fixture will be deleted. See [GoogleTest user's guide](https://google.github.io/googletest/primer.html#same-data-multiple-tests) for more details.
20
-
- R reusable test data: add code to the `prepare_test_data()` function in [`tests/testthat/helper-integration-tests-setup-run.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-setup-run.R), including code to save the new data object, e.g., `base::saveRDS(object, file = testthat::test_path("fixtures", "data_name.RDS"))`, and call `prepare_test_data()` in the `setup` section of the new test file to load the data using
21
-
```r
22
-
if (!file.exists(test_path("fixtures", "data_name.RDS"))) {
23
-
prepare_test_data()
24
-
}
25
-
```
26
-
- Use pre-existing integration data, e.g., `tests/testthat/fixtures/integration_test_data_components.RData` and `tests/testthat/fixtures/integration_test_data.RData`, by loading them within the `setup` section, e.g., `load(test_path("fixtures", "integration_test_data.RData"))` or within `prepare_test_data()`, where these data objects can be updated by running `R/data1.R`.
20
+
- R reusable test data: add code to the [`tests/testthat/helper-integration-tests-setup-wrappers.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-setup-wrappers.R) file, including code to save a new data or fit object for tests that use wrapper functions, e.g., `base::saveRDS(object, file = testthat::test_path("fixtures", "data_name.RDS"))` or `base::saveRDS(object, file = testthat::test_path("fixtures", "fit_name.RDS"))`, and call `load_fit_*()` in the `setup` section of the new test file to load the data.
21
+
- Use pre-existing integration data, e.g., `tests/testthat/fixtures/integration_test_data_components.RData` and `tests/testthat/fixtures/integration_test_data.RData`, by loading them within the `setup` section, e.g., `load(test_path("fixtures", "integration_test_data.RData"))`, where these data objects can be updated by running `R/data1.R`.
27
22
28
23
### :pencil: Edit the code in the new test file
29
24
@@ -33,8 +28,8 @@ Follow the structure of the new test file to write appropriate correctness, edge
33
28
34
29
The following :hammer: helper functions are available to assist with writing integration tests in R.
35
30
36
-
-`setup_and_run_FIMS_without_wrappers()`: Set up a FIMS model without wrappers (in [`tests/testthat/helper-integration-tests-setup-run.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-setup-run.R)).
37
-
-`setup_and_run_FIMS_with_wrappers()`: Set up a FIMS model with wrappers (in [`tests/testthat/helper-integration-tests-setup-run.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-setup-run.R)).
31
+
-`setup_and_run_FIMS_without_wrappers()`: Set up a FIMS model without wrappers (in [`tests/testthat/helper-integration-tests-setup-without-wrappers.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-setup-without-wrappers.R)).
32
+
-`load_*()`: Load or create data for a FIMS model run, or run a FIMS model with wrappers to save the fit output (in [tests/testthat/helper-integration-tests-setup-wrappers.R](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-setup-wrappers.R)).
38
33
-`verify_fims_deterministic()`: Compare the model output from a FIMS deterministic run against the expected "truth" from an operating model (in [`tests/testthat/helper-integration-tests-validation.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-validation.R)).
39
34
-`verify_fims_nll()`: Compare the negative log likelihood (NLL) from a FIMS model against the expected NLL calculated from an operating model (in [`tests/testthat/helper-integration-tests-validation.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-validation.R)).
40
35
-`validate_fims()`: Compare the output from a FIMS model where parameters are estimated against the expected "truth" from an operating model (in [`tests/testthat/helper-integration-tests-validation.R`](https://github.com/NOAA-FIMS/FIMS/blob/main/tests/testthat/helper-integration-tests-validation.R)).
0 commit comments