Automated tests own their data through factories, freeze clock time, have no order dependence, and deny outbound network unless a test is explicitly marked as integration.
Package status: reference context ready for human review. The contract and test scenarios are complete, but no claim is made that an adopting implementation has passed them.
Decision
Each automated test creates the data it needs through a fixture factory, then deletes or rolls back that data. Shared databases with leftover rows from other tests are banned. Time-sensitive logic uses an injectable clock that tests freeze. Test order is irrelevant: a method that passes alone must pass in any suite permutation. Outbound network is denied by default; tests that need a real collaborator are marked integration and run in a separate job.
Scope
- Unit and fast repository tests in CI: fixtures, transactions, clocks, isolation from other tests, and network policy.
- Backend automated suites that currently share a developer database.
- Distinguishing hermetic tests from marked integration tests.
Outside this block
- Contract testing between services.
- Production data seeding and anonymization.
Contract
- A test that needs a user, tenant, or aggregate calls a factory; it does not read a globally inserted row whose identity is shared across the suite.
- Database work either wraps in a transaction rolled back at teardown or uses a unique namespace per test identifier.
now()in domain code is obtained from a clock port; tests set a fixed instant and do not sleep for correctness.- Shuffling test order, or running a single test, cannot fail a previously passing hermetic test.
- Sockets to hosts other than the local test process are blocked unless the test or module is tagged
integration. - Fixture factories never depend on wall-clock uniqueness alone; they include the test id or a UUID.
Implementation
- Provide factories that build valid aggregates with only the overrides the test cares about.
- Inject a fake clock at test composition roots and fail CI if hermetic jobs record outbound connections.
Failure handling
- If teardown fails, error the test and do not reuse the polluted namespace.
- If a test opens a network socket without the integration mark, fail as a hermetic violation.
Verification
- Run the hermetic suite twice with shuffled order.
- Assert an expiry test passes with a frozen clock and that an accidental HTTP call fails the network guard.
The executable-looking examples in this package are fixtures and acceptance contracts. Run
python tools/validate.py from the collection root to check package structure and metadata; then
implement and execute the scenarios in the target repository.
Adoption assumptions
- Names and numeric values in
example.yamlare an adoption profile, not universal defaults. - The adopting team must map actors, data classes, error vocabulary, and ownership to its system.
References
- No external normative source is required; this package defines a project decision for hermetic automated tests.