← ClaudeAtlas

testing-and-coveragelisted

How the test suite works in this project — its PostgreSQL requirement, its fixtures, how to derive tests from specification scenarios, which edge cases matter here, and how to treat the 95% coverage floor honestly. Use when writing, fixing or reviewing tests.
vitoriarntrindade/pocketledger-openspec · ★ 0 · Testing & QA · score 63
Install: claude install-skill vitoriarntrindade/pocketledger-openspec
# Testing and coverage ## The suite is not hermetic, on purpose Tests run against **real PostgreSQL**, not SQLite. Money precision (`NUMERIC(12,2)`), referential integrity and the constraints that stop a category in use from being deleted are enforced by the database — testing them against a different engine would test something the product does not use. The cost is a prerequisite: ``` make test starts PostgreSQL, creates the test database, runs the suite make db just the database part ``` `scripts/dev-db.sh` is idempotent and additive: it starts the container only if it is not already healthy and creates `pocketledger_test` only if it is missing. It never drops or truncates anything. Running `pytest` directly without the database produces 81 collection errors, all of them the same missing connection. ## Always disable OTEL export in tests ```bash OTEL_ENABLED=false ENVIRONMENT=test JWT_SECRET=test-only pytest ``` Without it, the OTLP exporter retries against a collector that is not there, with backoff up to 32 seconds. The suite goes from about 43 seconds to roughly four minutes, and the result is buried in retry warnings. `make test` and `make quality` set this for you; a bare `pytest` does not. A test that genuinely needs a live tracer must build its own `TracerProvider` rather than depending on the application's global configuration — otherwise it passes or fails according to an environment variable, which is not a test. ## Fixtures Defined in