When adding or modifying tests, ensure they (1) cover the minimal correctness set (including edge/error paths), (2) validate key invariants so the test itself can’t silently be wrong, and (3) in E2E, assert the real semantics—not just the final API phase—while keeping timing bounded to avoid flakiness.
Practical rules 1) Include minimal error + edge cases for correctness
2) Assert invariants in the tests, not assumptions
3) In E2E, verify semantic behavior (signals/events/logs/watch), not just termination/scheduling
4) Use structured tests for completeness and maintainability
t.Helper() in custom must* helpers so failures point to the right call site.Example (Go unit test invariant helper)
func mustParseCPUSet(t *testing.T, s string) cpuset.CPUSet {
t.Helper()
set, err := cpuset.Parse(s)
if err != nil { t.Fatalf("parse %q: %v", s, err) }
return set
}
func requireDisjoint(t *testing.T, a, b cpuset.CPUSet) {
t.Helper()
if a.Intersection(b).Len() != 0 {
t.Fatalf("expected disjoint sets, overlap=%s", a.Intersection(b))
}
}
Example (E2E semantics verification idea)
Applying these standards will prevent both (a) correctness gaps where only the happy path is tested and (b) E2E regressions that “look fine” because the test checked a superficial outcome rather than the true semantics.