? (compared to subtract) The parameter order does not matter when_I_add_two_numbers_the_result_should_not_depend_on_parameter_order “add 1” twice is the same as doing “add 2” (compared to multiply) What about adding 0 ? Adding 0 does nothing We are confident the implementation is correct if we test these properties It applies to all inputs
the combination of an invariant with an input values generator. For each generated value, the invariant is treated as a predicate and checked whether it yields true or false for that value. As soon as there is one value which yields false, the property is said to be falsified, and checking is aborted. If a property cannot be invalidated after a specific amount of sample data, the property is assumed to be satisfied.
of the withdrawal amount when I have enough money Or the overdraft is authorized for my account I must not be allowed to withdraw when The withdraw amount is over my max withdrawal amount My balance is insufficient, and overdraft is not authorized for my account
property-based test can replace many example-based tests PBTs can reveal edge cases Nulls, negative numbers, weird strings (encoding for example), … PBTs ensures deep understanding of the business invariants Example-based tests are still helpful though Easier to understand & start with