Property-Based Testing

#139 - A Developer's Guide to Effective Software Testing - Mauricio Aniche

Topic 9 of 13

Published Jul 3, 2023 · Clip 38:49–42:04 (3:15)

Mauricio contrasts example-based testing (picking one concrete input) with property-based testing, where you describe a property of the program and a tool like jqwik generates many inputs (e.g., 1000) to assert the property holds. He gives examples: for any input greater than five the output is positive, and a custom set implementation must only contain unique elements regardless of insertion order. He notes property-based testing is harder to write since you must think in properties rather than specific functionality, and that in building information systems there are fewer opportunities—example-based remains the default, with property-based testing useful when one example feels insufficient.