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
@@ -41,6 +40,7 @@ This document describes how to set up a development environment to modify, build
41
40
-[Running Tests](#running-tests)
42
41
-[Selecting tests with markers](#selecting-tests-with-markers)
43
42
-[External model tests](#external-model-tests)
43
+
-[Writing tests](#writing-tests)
44
44
45
45
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
46
46
@@ -237,7 +237,6 @@ MODFLOW 6 tests are driven with [`pytest`](https://docs.pytest.org/en/7.1.x/), w
237
237
238
238
A few tasks must be completed before running tests:
239
239
240
-
## Testing
241
240
- build local MODFLOW 6 development version
242
241
- rebuild the last MODFLOW 6 release
243
242
- install additional executables
@@ -362,6 +361,8 @@ pytest -v -n auto
362
361
Markers can be used to select subsets of tests. Markers provided in `pytest.ini` include:
363
362
364
363
-`slow`: tests that take longer than a few seconds to complete
364
+
-`repo`: tests that require external model repositories
365
+
-`large`: tests using large models (from the `modflow6-examples` and `modflow6-largetestmodels` repos)
365
366
-`regression`: tests comparing results from multiple versions
366
367
367
368
Markers can be used with the `-m <marker>` option, and can be applied in boolean combinations with `and`, `or` and `not`. For instance, to run fast tests in parallel, excluding regression tests:
@@ -386,18 +387,39 @@ Tests using models from external repositories can be selected with the `repo` ma
386
387
pytest -v -n auto -m "repo"
387
388
```
388
389
389
-
The test scripts can also be run independently:
390
+
The `large` marker is a subset of the `repo` marker. To test models excluded from commit-triggered CI and only run on GitHub Actions nightly:
391
+
392
+
```shell
393
+
pytest -v -n auto -m "large"
394
+
```
395
+
396
+
Test scripts for external model repositories can also be run independently:
390
397
391
398
```shell
392
-
#Run MODFLOW 6 test models
399
+
# MODFLOW 6 test models
393
400
pytest -v -n auto test_z01_testmodels_mf6.py
394
401
395
-
#Run MODFLOW 5 to 6 conversion test models
402
+
# MODFLOW 5 to 6 conversion test models
396
403
pytest -v -n auto test_z02_testmodels_mf5to6.py
397
404
398
-
#Run example models
405
+
#models from modflow6-examples repo
399
406
pytest -v -n auto test_z03_examples.py
400
407
401
-
#Run large test models
408
+
#models from modflow6-largetestmodels repo
402
409
pytest -v -n auto test_z03_largetestmodels.py
403
410
```
411
+
412
+
Tests load external models from fixtures provided by `modflow-devtools`. External model tests can be selected by model or simulation name, or by packages used. See the [`modflow-devtools` documentation](https://modflow-devtools.readthedocs.io/en/latest/md/fixtures.html#filtering) for usage examples. Note that filtering options only apply to tests using external models, and will not filter tests defining models in code — for that, the `pytest` built-in `-k` option may be used.
413
+
414
+
#### Writing tests
415
+
416
+
Tests should ideally follow a few conventions for easier maintenance:
417
+
418
+
- Use temporary directory fixtures. Tests which write to disk should use `pytest`'s built-in `tmp_path` fixtures or one of the [keepable temporary directory fixtures from `modflow-devtools`](https://modflow-devtools.readthedocs.io/en/latest/md/fixtures.html#keepable-temporary-directories). This prevents tests from polluting one another's state.
419
+
420
+
- Use markers for convenient (de-)selection:
421
+
-`@pytest.mark.slow` if the test doesn't complete in a few seconds (this preserves the ability to quickly [`--smoke` test](https://modflow-devtools.readthedocs.io/en/latest/md/markers.html#smoke-testing)
422
+
-`@pytest.mark.repo` if the test relies on external model repositories
423
+
-`@pytest.mark.regression` if the test compares results from different versions
424
+
425
+
The test suite must pass before code can be merged, so be sure it passes locally before opening a PR.
0 commit comments