User Tools

Site Tools


property-based_testing

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
property-based_testing [2025/09/09 19:16] – created plidaproperty-based_testing [2025/09/09 19:18] (current) plida
Line 3: Line 3:
 ====== Property-based testing ====== ====== Property-based testing ======
  
-PBT is an approach to testing in which we test the properties of a function rather than individual examples. Instead of a single test with specific input data, the framework generates hundreds of random cases.+PBT is an approach to [[software_testing|testing]] in which we test the properties of a function rather than individual examples. Instead of a single test with specific input data, the framework generates hundreds of random cases.
  
 ==== Strengths of PBT ==== ==== Strengths of PBT ====
Line 11: Line 11:
   - Automatically generates hundreds of inputs.   - Automatically generates hundreds of inputs.
   - Reduces the risk of "bias", when tests check only "convenient" cases.   - Reduces the risk of "bias", when tests check only "convenient" cases.
 +
 +==== Best practices ====
 +
 +  - Formulate properties at the domain level.
 +  - Don't overuse PBT: for complex business logic, you also need regular tests.
 +  - Use a fixed seed for reproducibility.
 +  - Combine PBT with [[random-based_tests|random-based]] and sample tests.
property-based_testing.1757445415.txt.gz · Last modified: by plida