-
WHAT
- Property based testing relies on properties. It checks that a function, program or whatever system under test abides by a property
-
Property-based tests make statements about the output of your code based on the input, and these statements are verified for many different possible inputs- Jessica Kerr (@jessitron)
- A property-based testing framework runs the same test over and over with generated input
- Property-based testing is generative testing
-
Property-based tests are designed to test the aspects of a property that should always be true
- They allow for a range of inputs to be programmed and tested within a single test, rather than having to write a different test for every value that you want to test
- was popularized by the Haskell library QuickCheck
- Tests that are similar to property-based tests include fuzz testing, or the use of example tables in ATDD/BDD-style testing
- Where a property is a high-level specification of behavior that should hold for a range of data points
- A kind of random testing (Eric Normand of PurelyFunctional.tv)
-
Write test
- Define the behaviors you are looking to test
- Define the range of data you want to use to check against each outcome
- Use a library in your code language to generate data sets (either random or specified) to use in your tests
- Write and run tests
-
Benefits
- Cover the scope of all possible inputs
- Shrink the input in case of failure
- Reproducible and replayable
-
Sources
- https://medium.com/criteo-labs/introduction-to-property-based-testing-f5236229d237#:~:text=Definition,be%20seen%20in%20the%20output.
- https://medium.com/@vporoshok/property-based-testing-642cb7f9817f
- https://jqwik.net/property-based-testing.html
- https://dev.to/jdsteinhauser/intro-to-property-based-testing-2cj8
- https://techbeacon.com/app-dev-testing/how-make-your-code-bulletproof-property-testing
- https://jessitron.com/2013/04/25/property-based-testing-what-is-it/
- https://medium.com/russell-duhon/property-based-testing-from-scratch-in-python-bb1a8b56daf6
- https://habr.com/ru/company/mailru/blog/494110/
- https://habr.com/ru/post/434008/
- https://www.scalatest.org/user_guide/property_based_testing
- https://xpirit.com/property-based-testing/
- https://increment.com/testing/in-praise-of-property-based-testing/
- https://testguild.com/property-based-testing/