Règle #3 : les tests observent, ils ne façonnent pas le code #136
@@ -18,6 +18,13 @@ When adding behavior or tests would grow a Rust file and leave it above 500 line
|
||||
- Group integration tests by behavior in the package's top-level `tests/` directory and exercise the public API.
|
||||
- When documenting a runnable API example, use a Rust code block in the item's `///` comments so `cargo test` checks it.
|
||||
|
||||
## Rule #3: tests observe, they don't shape
|
||||
|
||||
Production code does not exist to satisfy a test. Tests go through the same paths production uses; when a test needs a way in, that is a design seam with a production meaning (an injected clock, a trait with a real implementation), not a test hook.
|
||||
|
||||
- No `cfg(test)` / `cfg!(test)` branches inside production logic, no flags or parameters only tests set, no visibility widened only for tests.
|
||||
- Exception: passive instrumentation under `#[cfg(test)]` (counters, recorded events) that guards a Rule #1 structural test, never read by production code and never changing its behaviour.
|
||||
|
||||
## Agent skills
|
||||
|
||||
### Issue tracker
|
||||
|
||||
Reference in new issue
Block a user