Pretend we know as much science as the ancient philosophers. (Philosophy was the closest thing to science they had in ancient times.) We might observe that rainwater in the parking lot moves toward the grates. “Why?” we ask each other. Does water like grates? Is it afraid of sunlight? Is each droplet shepherded in that direction by the Goddess of Rainwater? or does each droplet feel a societally-imposed moral compulsion to plunge itself into darkness?
It is a long jump from water skimming across the concrete toward the sewer to the principle of gravity, to the mass of each water molecule drawn toward the mass of all the molecules in the Earth. This property of matter causes rainwater to move down, and the shape of the parking lot translates “toward the center of the Earth” into “mostly sideways toward the low point with the grate.” We need more observations and a great deal of reflection to recognize the observed behaviour as a logical consequence of a universal principle.
It took thousands of years to understand the principle of gravity, but it was worth it. Knowing the principle lets us predict the motion of water (and other things) on arbitrary surfaces that do not contain grates.
Move from observed behaviour of objects to established properties of types and we gain this predictive power in our programs. Example-based testing establishes behaviour; property-based (aka generative) testing documents inherent properties. As humans it is easier to generalize from a few examples than from the careful mathematical expression of a property. Yet, it’s also much easier to generalize inaccurately and reason poorly looking at a few cases of rainwater in parking lots than when considering all abstract cases of matter.
Property-based testing. It’s a thing. And it’s only the beginning.