Property-Based Testing
Property-based testing checks general rules about software against many generated inputs. When a rule fails, the testing library searches for a smaller counterexample that makes the defect easier to understand and reproduce.
itSoftware engineering | OpenSkills.info
Course pathWalk it in order
Look it upDip in anytime
Go furtherLeaves this page
Don't Panic
Don't Panic: Property-Based Testing
Property-based testing is the habit of testing a rule instead of assembling a long guest list of preferred inputs. A named example says that sorting this particular list should return that particular order. A property says that sorting keeps the same elements, keeps the same length, and puts them in order for every generated list the test can reasonably explore. The examples are still welcome. They carry business meaning. The property is there because software has an alarming talent for meeting the invitation and misbehaving everywhere else.
The machinery has five jobs. A property states the rule. A generator describes the input domain. The runner repeats the test, and a shrinker tries to reduce any failure to a smaller counterexample. The report then preserves the reduced case and replay information. This is why a failure involving a five-hundred-item structure can eventually arrive wearing a two-item hat and looking much less mysterious.
The surprising part is that randomness does not confer wisdom. A generator that produces mostly empty arrays can produce an impressive stack of passing results while avoiding the behavior that matters. A broad generator followed by many discarded cases has the same problem in a different coat. Construct valid values directly, generate related fields together, and inspect classifications or coverage statistics. The generator is not a vending machine for test data. It is part of the argument that the test examined something useful.
A counterexample also needs stable surroundings. Hidden time, scheduling, network responses, shared mutable state, or another random source can make the same input pass on Tuesday and fail on Wednesday. Shrinking cannot make a moving target polite. Control those dependencies, then retain the concrete counterexample along with a replay token or seed. The seed can help repeat a generation path, but the counterexample is the evidence that survives changes in library settings.
For a map of the moving parts, open the Slides. The Intro explains property patterns, generator design, shrinking, and stateful testing in full. The Cheatsheet is the quick reference when a discard rate rises or a counterexample refuses to reproduce. The Practice tab turns a compact contract into a reviewable test design, and the Exercise uses sorting to make the whole arrangement fail safely before it passes usefully. The Quiz checks whether the vocabulary has stopped disguising itself as magic.
Where this skill leads
Relevant careers
See how this topic contributes to broader role-level skill maps.
Sources
- https://research.chalmers.se/en/publication/237427
Supports
- Definition of properties as executable functions checked against generated input
- Custom generators, distribution observation, and limitations of random testing
- September 2000 QuickCheck timeline milestone
- Quiz answers about the defining property-based structure
- https://hackage.haskell.org/package/QuickCheck
Supports
- Current QuickCheck generator, property, distribution, and monadic-testing capabilities
- Open-source licensing and free availability for Landscape placement
- https://hypothesis.works/articles/what-is-property-based-testing/
Supports
- Distinction between essential property-based testing behavior and library-specific mechanisms
- Relationship between property-based testing and fuzzing
- Property patterns and quiz answer about idempotence
- https://hypothesis.readthedocs.io/en/latest/reference/strategies.html
Supports
- Strategy composition, dependent data, recursive generation, shrinking, and reproducible pseudorandom state
- Generator design and reproduction guidance
- Quiz answers about recursive generators and replay
- https://hypothesis.readthedocs.io/en/latest/reference/api.html
Supports
- Explicit, replay, generate, target, shrink, and explain phases
- Minimal failing examples and replay behavior
- https://hypothesis.readthedocs.io/en/latest/stateful.html
Supports
- Rules, bundles, state-machine action sequences, and reduced failing programs
- Stateful architecture and quiz answer
- https://hypothesis.readthedocs.io/en/latest/compatibility.html
Supports
- Requirement for deterministic outcomes and deterministic data generation
- Quiz answer about nondeterminism during shrinking
- https://hypothesis.works/articles/how-hypothesis-works/
Supports
- Unified byte-stream representation for generation, replay, and shrinking
- Hypothesis 3.0 engine timeline milestone in 2016
- https://fast-check.dev/docs/introduction/what-is-property-based-testing/
Supports
- Differences between example and property tests
- Random generation, multiple runs, and counterexample shrinking
- Test-runner integration and quiz answers about the core pipeline
- https://fscheck.github.io/FsCheck/TestData.html
Supports
- Generator, shrinker, and Arbitrary relationships
- Constructive generation, type-derived data, and shrinking behavior
- FsCheck Landscape placement and quiz answer about shrinking
- https://fscheck.github.io/FsCheck/Properties.html
Supports
- Preconditions, quantified properties, custom generators, and avoiding filtered cases
- Quiz answers about direct generation and discard rates
- https://jqwik.net/docs/current/user-guide
Supports
- Properties, arbitraries, assumptions, shrinking, edge cases, statistics, and stateful actions
- Generator distribution and discard diagnostics
- jqwik Landscape placement and quiz answers about valid domains
- https://research.chalmers.se/publication/517894/file/517894_Fulltext.pdf
Supports
- Systematic patterns for writing independent properties of pure functions
- Model, invariant, and metamorphic property design
- Quiz answers about circular oracles and differential disagreement
- https://proper-testing.github.io/
Supports
- Erlang property generation, targeted testing, and model-based use
- PropEr Landscape placement
- https://pure.york.ac.uk/portal/en/publications/smallcheck-and-lazy-smallcheck-automatic-exhaustive-testing-for-s-2/
Supports
- Bounded exhaustive generation as an alternative to random sampling
- 2008 SmallCheck timeline milestone
- https://proper-testing.github.io/publications.html
Supports
- September 2011 PropEr types and specifications publication
- PropEr timeline milestone
- https://arxiv.org/abs/1409.0393
Supports
- Property-based design of information-flow abstract machines and counterexamples for seeded defects
- September 2014 timeline milestone
- https://proper-testing.github.io/papers/issta2017.pdf
Supports
- Search objectives and optimization in targeted property-based testing
- Generator-distribution guidance and July 2017 timeline milestone
- https://arxiv.org/abs/1808.01520
Supports
- Branching-process analysis of recursive generator constructor counts
- August 2018 timeline milestone
- https://joss.theoj.org/papers/10.21105/joss.01891
Supports
- Hypothesis generation and test-case-reduction architecture
- November 2019 timeline milestone
- https://arxiv.org/abs/2404.16062
Supports
- Parallel property execution and deterministic versus greedy parallel shrinking
- April 2024 timeline milestone
- https://github.com/sindresorhus/awesome
Supports
- Discovery path to the Awesome Testing list
- https://github.com/TheJambo/awesome-testing
Supports
- Scope decision that the general list excludes unit-test resources and requires a more specific list
- https://github.com/cleder/awesome-python-testing
Supports
- Discovery of Atheris, HypoFuzz, hypothesis-crosshair, and icontract-hypothesis
- https://pypi.org/project/atheris/
Supports
- Coverage-guided fuzzing of Python and CPython extensions
- Atheris Awesome Links rationale
- https://hypofuzz.com/docs/
Supports
- Adaptive coverage-guided execution of Hypothesis tests and shared failure database
- HypoFuzz Awesome Links rationale
- https://hypothesis.readthedocs.io/en/latest/extensions.html
Supports
- CrossHair solver backend, HypoFuzz backend, failure database, and normal shrinking integration
- Hypothesis CrossHair Awesome Links rationale
- https://pypi.org/project/icontract-hypothesis/
Supports
- Strategy inference from preconditions and generated test tooling
- icontract-hypothesis Awesome Links rationale
- https://hypothesis.readthedocs.io/
Supports
- Python strategy, example-database, shrinking, and stateful-testing capabilities
- Open-source licensing and free availability for Landscape placement
- https://fast-check.dev/
Supports
- JavaScript and TypeScript arbitraries, shrinking, and test-runner integration
- Open-source licensing and free availability for Landscape placement
- https://scalacheck.org/
Supports
- Scala and Java properties, generated parameters, standalone operation, and framework integration
- ScalaCheck Landscape placement
- https://fscheck.github.io/FsCheck/
Supports
- F sharp and C sharp properties, generators, shrinkers, and framework integration
- BSD licensing and free availability for Landscape placement
- https://github.com/hedgehogqa/haskell-hedgehog
Supports
- Integrated generation and shrinking for composed Haskell generators
- Open-source licensing and free availability for Landscape placement
- https://proptest-rs.github.io/proptest/
Supports
- Per-value Rust strategies, shrinking, failure persistence, recursive data, and state-machine support
- Open-source licensing and free availability for Landscape placement
- https://www.hetzner.com/blog/cloud-api-backend-rewrite-and-property-based-testing/
Supports
- State-aware generation of valid API action sequences and comparisons after each action
- The time cost and reproducibility limits of shrinking tests that change real infrastructure
- Field Notes guidance for stateful testing and external-system shrink budgets
- https://link.springer.com/article/10.1007/s10664-026-10953-w
Supports
- Input data generation as the largest category in the study of 213 Hypothesis-related developer questions
- Field Notes guidance that generator design is the adoption difficulty to address first
- https://fast-check.dev/docs/introduction/getting-started/
Supports
- fast-check setup and property assertion patterns used by the practice reference and exercise
