- Introduced a new job in the CI workflow to run backend tests before the build process. - Configured Python environment and installed dependencies from the backend requirements. - Added a check for the TEST_DATABASE_URL secret to ensure it is defined before running tests. - The test job must pass for the build job to execute, enhancing the reliability of the CI pipeline.
35 lines
905 B
Markdown
35 lines
905 B
Markdown
# Backend test strategy (Anexo24)
|
|
|
|
## Test suites
|
|
|
|
- `tests/e2e/`: full business flow (catalogs -> import -> export -> balances/discharges).
|
|
- `tests/integration/`: process API behavior and edge cases.
|
|
- `tests/unit/`: critical algorithms only (no trivial CRUD tests).
|
|
|
|
## Prerequisites
|
|
|
|
- PostgreSQL test database available.
|
|
- Environment variable:
|
|
- `TEST_DATABASE_URL=postgresql://user:pass@host:5432/db_name`
|
|
|
|
## Run commands
|
|
|
|
- Fast subset (CI gate):
|
|
- `pytest -q tests/unit tests/integration`
|
|
- Full suite:
|
|
- `pytest -q tests`
|
|
- `pytest tests -v -ra`
|
|
- `pytest tests -v -ra -s`
|
|
- E2E only:
|
|
- `pytest -q tests/e2e`
|
|
|
|
## CI recommendations
|
|
|
|
- Pull request gate:
|
|
- Run unit + integration on every PR.
|
|
- Nightly / main branch:
|
|
- Run full suite including E2E.
|
|
- Keep Celery eager mode for deterministic process endpoint tests:
|
|
- `task_always_eager=True`
|
|
- `task_eager_propagates=True`
|