Back to library

🧪Property-Based Testing

Go beyond example-based tests — learn to express what your code should always do, then let a framework find the inputs that break it.

Advanced14 drops~2-week path · 5–8 min/daytechnology

Phase 1What Properties Really Are

From examples to universal claims about your code

4 drops
  1. One property beats a hundred examples

    6 min

    One property beats a hundred examples

  2. Five patterns that cover most properties

    7 min

    Five patterns that cover most properties

  3. Your framework already generates the inputs

    7 min

    Your framework already generates the inputs

  4. Stop thinking in test cases, start thinking in contracts

    6 min

    Stop thinking in test cases, start thinking in contracts

Phase 2Properties for Pure Functions

Write real properties for pure functions

5 drops
  1. Encode, decode, and get back where you started

    7 min

    Encode, decode, and get back where you started

  2. What doesn't change tells you what the function really does

    7 min

    What doesn't change tells you what the function really does

  3. Test your fast code against your slow code

    7 min

    Test your fast code against your slow code

  4. Your function might already obey algebraic laws

    7 min

    Your function might already obey algebraic laws

  5. Small properties compose into strong specifications

    6 min

    Small properties compose into strong specifications

Phase 3Generators, Shrinking, and State

Generators, shrinking, and stateful models

4 drops
  1. When random strings waste your testing budget

    7 min

    When random strings waste your testing budget

  2. 47 elements found the bug, but only 3 mattered

    7 min

    47 elements found the bug, but only 3 mattered

  3. Your API has state — and property testing can model it

    8 min

    Your API has state — and property testing can model it

  4. Your team says property tests are too slow for CI

    7 min

    Your team says property tests are too slow for CI

Phase 4Find a Real Bug

Find a real bug with property tests

1 drop
  1. Property-test a real module and find what's hiding

    8 min

    Property-test a real module and find what's hiding

Frequently asked questions

How do I think of good properties?
This is covered in the “Property-Based Testing” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
What is shrinking?
This is covered in the “Property-Based Testing” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
When are example tests still better?
This is covered in the “Property-Based Testing” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.
Does property testing replace unit tests?
This is covered in the “Property-Based Testing” learning path. Start with daily 5-minute micro-lessons that build from fundamentals to hands-on application.