Testing¶
Purpose¶
Tests should demonstrate the behavior a change protects, not merely execute
code. The commands below are intended for contributors working from a source
checkout and use the supported monstim Conda environment.
Run tests¶
# Focused test while developing (use a new run ID each time on Windows)
conda run -n monstim python -m pytest tests/gui/test_help_navigation.py -q --basetemp C:\tmp\monstim-pytest-<run-id> -p no:cacheprovider
# Default suite (legacy tests remain excluded by pytest configuration)
conda run -n monstim python -m pytest -q --basetemp C:\tmp\monstim-pytest-<run-id> -p no:cacheprovider
# Include legacy-marked tests when intentionally checking them
conda run -n monstim python -m pytest -m "legacy or not legacy" -q --basetemp C:\tmp\monstim-pytest-<run-id> -p no:cacheprovider
Replace <run-id> with a unique value, and remove only that exact temporary
directory after a successful run. Use -k <expression> or a precise node ID
to narrow a failure. For GUI tests, retain the offscreen configuration used by
the test suite and avoid relying on timing or a visible desktop.
Test design¶
- Put pure signal and domain behavior in focused unit or domain tests.
- Exercise repository, import/export, command, and hierarchy behavior with integration tests.
- Use
tmp_pathor pytest-managed temporary locations for every write. - Treat files under
tests/fixturesas read-only inputs. - Verify an undo/redo round trip for every undoable mutation.
- For a bug fix, add the smallest regression test that fails before the fix.
Before handoff¶
conda run -n monstim ruff check <touched Python paths>
git diff --check
Run broader tests when the change crosses domain, persistence, or GUI boundaries.