property-based-testing
Installation
SKILL.md
Property-Based Testing
Instead of testing specific examples, define properties that must hold for ALL inputs. The framework generates hundreds of random inputs and finds the smallest failing case.
When to Use PBT
| Use Case | Property |
|---|---|
| Serialization roundtrip | deserialize(serialize(x)) === x |
| Sort function | Output is ordered AND contains same elements |
| Parser | Never crashes on any input |
| Encoder/decoder | decode(encode(x)) === x |
| State machine | Invariants hold after any sequence of operations |
| Math/financial | Associativity, commutativity, identity, bounds |
| API handler | Never returns 500 on valid input |
| Data transformation | Output schema matches specification |