From b6b032a51c1e2ffeed6a7b72eb51788f6307e451 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Thu, 29 Oct 2026 21:45:44 +0100 Subject: [PATCH] Update AGENTS.md --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index 1c5fae6a0..08e6b4e60 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -88,6 +88,7 @@ integration_test/ screenshot driver ## Tests - **Prove a test can fail.** After writing one, break the production side it guards (flip a type, delete the branch, drop a registry entry) and watch it go red, then restore. A test nobody has seen fail is a guess. This is how the suite grew tests that could never fail: a finder comparing element types against a widget type, an `every(...)` without an `expect`, a `contains('10')` that the prefilled `100` already satisfied, a file without the `_test` suffix that the runner never collected. +- **Don't test library behavior.** No tests that only show that Drift stores a column, Riverpod rebuilds, freezed generates `copyWith`/`==` or `json_serializable` maps a field; test our own code (custom mappings, overrides, logic). - **Layering:** repositories are tested against a real in-memory Drift DB (`test/helpers/in_memory_drift.dart`), notifiers against a mocked repository (`MockFooRepository`, never a `_FakeFoo extends Foo`), widgets with `authProvider.overrideWith(() => FakeAuthNotifier(...))` from `test/helpers/fake_auth_notifier.dart` instead of seeding prefs and stubbing every auto-login request. One test file per source file, mirroring its path. - **Test the clearing, not just the change.** Every bug this rule would have caught came from a null crossing a boundary: `toCompanion()` mapping null to `Value.absent()` (an update then leaves the column untouched), a hand-written `copyWith` with `?? this.x` swallowing a cleared field. When a field becomes editable, assert non-null → null against the stored row, not only non-null → non-null. - **Test the boundary day of a date range.** Callers pass calendar days, entries carry timestamps, and the mismatch hides in the edges: an entry recorded during the end day, the day after, the start day. Same for anything counting days: `difference().inDays` measures elapsed time, so a range spanning the spring-forward switch comes up one day short. Count calendar days as UTC midnights.