Loading...
Loading...
Use when writing tests for serialization, validation, normalization, or pure functions - provides property catalog, pattern detection, and library reference for property-based testing
npx skill4agent add ed3dai/ed3d-plugins property-based-testing| Property | Formula | When to Use |
|---|---|---|
| Roundtrip | | Serialization, conversion pairs |
| Idempotence | | Normalization, formatting, sorting |
| Invariant | Property holds before/after | Any transformation |
| Commutativity | | Binary/set operations |
| Associativity | | Combining operations |
| Identity | | Operations with neutral element |
| Inverse | | encrypt/decrypt, compress/decompress |
| Oracle | | Optimization, refactoring |
| Easy to Verify | | Complex algorithms |
| No Exception | No crash on valid input | Baseline (weakest) |
No Exception -> Type Preservation -> Invariant -> Idempotence -> Roundtrip| Pattern | Property | Priority |
|---|---|---|
| Roundtrip | HIGH |
| Roundtrip | HIGH |
| Pure functions with clear contracts | Multiple | HIGH |
| Idempotence | MEDIUM |
| Valid after normalize | MEDIUM |
| Sorting, ordering, comparators | Idempotence + ordering | MEDIUM |
| Custom collections (add/remove/get) | Invariants | MEDIUM |
| Builder/factory patterns | Output invariants | LOW |
| Language | Library | Import |
|---|---|---|
| Python | Hypothesis | |
| TypeScript/JS | fast-check | |
| Rust | proptest | |
| Go | rapid | |
| Java | jqwik | |
| Haskell | QuickCheck | |
@ed3d-research-agents:internet-researcherassume()# GOOD
st.integers(min_value=1, max_value=100)
# BAD - high rejection rate
st.integers().filter(lambda x: 1 <= x <= 100)st.lists(st.integers(), max_size=100)
st.text(max_size=1000)st.integers(min_value=0, max_value=150) # Real ages, not arbitrary intsvalid_users = st.builds(User, ...)
@given(valid_users)
def test_one(user): ...
@given(valid_users)
def test_two(user): ...# Development (fast feedback)
@settings(max_examples=10)
# CI (thorough)
@settings(max_examples=200)
# Nightly/Release (exhaustive)
@settings(max_examples=1000, deadline=None)assume()@exampleassert sorted(xs) == sorted(xs)assume()assert add(a, b) == a + b@example([])@example([1])assume()| Mistake | Fix |
|---|---|
| Testing mock behavior | Test real behavior |
| Reimplementing function in test | Use algebraic properties |
| Filtering with assume() | Build constraints into strategy |
| No edge case examples | Add @example decorators |
| One property only | Add multiple properties (length, ordering, etc.) |