--- name: principle-test-behavior-not-implementation description: "Apply when you write, change, or keep a test. Call the code the way its users do and assert the result they observe against a literal expected value. If the test would still pass when every imported function returns undefined, rewrite the assertion or delete the test." --- # Principle test behavior not implementation Tests should exercise the subject through a user-facing or executable interface and compare observable results against independently justified expectations. Rewrite tests that compare a value with itself, derive expectations by repeating the implementation, inspect source strings instead of behavior, or only assert fixtures they created. Weak existence/truthiness checks and mock-call counts often miss real failures. Use concrete inputs and literal expected outputs where appropriate. For absence cases, include a contrasting positive case. Verify meaningful mock payloads or resulting state. Test the behavior controlled by a constant rather than merely restating it. Relation checks across tables and compile-time type contracts can be valid. Keep tests that distinguish plausible bugs; remove tests that cannot.