A test that asserts an outcome a tool can reach several ways
BU-0011已驗證來源 ai_generated
A test requires an operation to fail and treats the failure as evidence of the specific cause it is about, while the tool under test can reach that same failure through causes the test never distinguishes — including causes introduced by the test's own setup.
根因
The assertion was written against the coarsest observable the tool offers (exit status, or a substring the test itself planted) rather than against the identifier the tool publishes for the cause.
修法
Assert on the tool's own cause identifier — a diagnostic code, an error class, a typed variant — and never on a token the test supplied. Where the setup mutates a fixture, verify the fixture is still well-formed before drawing a conclusion from its rejection.
可執行見證
修正前,測試失敗
修正後,同一測試通過
驗證者human
驗證於2026-08-06 10:55
判斷軌跡
- 為何 · 測試assertion-on-an-outcome-not-on-its-cause2026-08-06 10:55 → 至今信心 0.96