Testing¶
Run the smallest relevant test while developing, then run the complete local checks before opening a pull request. Tests must use fabricated identities and documents.
Backend tests¶
From the repository root:
PowerShell¶
backend\.venv\Scripts\python.exe -m pytest backend\tests -q
Bash¶
backend/.venv/bin/python -m pytest backend/tests -q
If the backend environment does not exist, create and install it first as described in Installation.
Backend tests cover:
- authentication and assurance boundaries;
- API request and response contracts;
- intent compilation and route selection;
- journey creation, progress, and milestone transitions;
- document metadata, consent, and access control;
- provider adapter failures and timeouts.
Sandbox integration tests¶
Tests that call a provider sandbox are opt-in because they require authorized credentials, network access, and may consume credits:
RUN_EGOV_AI_SANDBOX_TESTS=true pytest -m sandbox
Never enable sandbox tests in an untrusted fork or paste their output into public issue trackers without reviewing it.
Flutter checks¶
From frontend/:
flutter pub get
flutter analyze
flutter test
Use widget tests for stateful navigation, chat transitions, form validation, and dynamic workflow rendering. Use golden tests sparingly for stable, high-value visual states and review intentional pixel changes.
Documentation checks¶
From the repository root:
PowerShell¶
.venv-docs\Scripts\python.exe -m mkdocs build --strict
Bash¶
.venv-docs/bin/python -m mkdocs build --strict
Strict mode fails on navigation and reference warnings. Also review the generated site at phone, tablet, and desktop widths after changing the theme.
Test data rules¶
Use obviously fictional names, addresses, document numbers, images, and provider responses. Do not:
- commit access tokens, exchange codes, session IDs, face images, or QR payloads;
- use a real citizen account in an automated test;
- record provider traffic containing personal data;
- snapshot authorization headers or signed storage URLs.