3 ms·
The article separates types from property testing, I can sympathize, it is true, it makes sense. But testing is a tool for reliability to be used in conjunctio
by iso8859-1 5y ago
The article separates types from property testing, I can sympathize, it is true, it makes sense.
But testing is a tool for reliability to be used in conjunction with so many other tools like, you guessed it, typing.
In 2016 when this article was written, typing wasn't yet popular in Python. But now it is, and indeed more popular than property testing will ever be.
But Hypothesis doesn't support typing very well, though they do attempt [0]. But just take a look at that list of caveats. It is a hack job in comparison.
Even if you don't generate your Strategies from types, Hypothesis requires you to know whether the type you construct is internally a sum type or a product type. [1] The testing framework shouldn't have to know these details, this is unnecessary complexity.
If you think the QuickCheck strategy of having lawless unnamed instances is bad, there is now a Haskell library[2] where Gens are values, like they are in Hypothesis (where they are called Strategies). It probably became popular only after 2016, which could be why the article doesn't mention it. Hypothesis also supports "registering" strategies so that they are auto-discovered on-demand. It's done at runtime of course, unlike with QuickCheck, where it is type class based, as previously mentioned.
I applaud the article for cementing that property checking can work without typing, but I worry that readers will conclude that Haskell does it wrong, which is a false implication. You don't have to use ad-hoc polymorphism for discovering strategies.
[0]: https://hypothesis.readthedocs.io/en/latest/data.html#hypothesis.strategies.from_type https://hypothesis.readthedocs.io/en/latest/data.html#hypoth...
[1]: https://github.com/HypothesisWorks/hypothesis/issues/2693#issuecomment-740825110 https://github.com/HypothesisWorks/hypothesis/issues/2693#is...
[2]: https://hackage.haskell.org/package/hedgehog#readme https://hackage.haskell.org/package/hedgehog#readme