I’d like to point out that property testing is attainable in lower level languages, e.g. C/C++. See my data structures library with python bindings and using the excellent hypothesis library:
Thank you DRMacIver.
There’s a nice C library for this sort of testing as well: https://github.com/silentbicycle/theft
Theft is great (sentences to take out of context…) but the major problem with it is that it doesn’t come with any sort of library of data generators or shrinkers, so it’s extremely DIY. Most of the work in doing this sort of thing is writing those generators and shrinkers, so it really helps to have a pre-built library of them rather than having to roll your own.
I’ll grant that rolling your own is very in the spirit of the language, but I’d still rather not do it if I don’t have to and I’m probably as close as it gets to being an expert in the subject. :-)
I did look into theft. But this is where I find scripting language much more pleasant to work with. Hypothesis comes with automatic ‘reduction’ functions, while in theft you have to implement all of this.
Writing the equivalent testing functionnality with theft would have probably taken as much code as the testee’s code.
This is exactly the sort of toe-hold I was hoping for, when I complained the other day about not knowing how to get started. Thanks for writing this up!
I would call this style Fuzzing, more than property based testing, but it’s a valid technique
I don’t really think there’s a hard and fast line between fuzzing and property based testing. They’re two different points on a fairly continuous spectrum. It’s easy to add properties to your fuzzers (and every fuzzer is implicitly testing the very coarse grained property “it doesn’t crash”), and every property-based test is also intrinsically fuzzing your code.