3 ms·
For the past few months I've been writing property tests with Hypothesis for Python (https://hypothesis.readthedocs.io/en/latest/ https://hypothesis.readthedocs
by maxbond 6y ago
For the past few months I've been writing property tests with Hypothesis for Python (https://hypothesis.readthedocs.io/en/latest/ https://hypothesis.readthedocs.io/en/latest/) and Proptest for Rust (https://altsysrq.github.io/proptest-book/intro.html https://altsysrq.github.io/proptest-book/intro.html). The tl;dr on property testing is that, rather than testing just one manually solved case, you describe an invariant (the example given of x + y < limit being a good one) and a method of generating random inputs, and the test runner will use that information to fuzz your code.
I've found that I get better tests, and that I can write tests faster. It's also an antidote to Unangst's point that the developer who failed to imagine an test case while programming won't necessarily have an epiphany when they go to write tests.
But it isn't always a good fit with one's domain.