3 ms·
I love Hypothesis. I can't find many practical uses for it (it's more useful in more "algorithmic" code, rather than for interactive apps), but it's fantastic i
by StavrosK 11y ago
I love Hypothesis. I can't find many practical uses for it (it's more useful in more "algorithmic" code, rather than for interactive apps), but it's fantastic in what it does.
- DRMacIver 11y agoHave you seen the talk I did about using it with Django? http://www.drmaciver.com/2015/06/hypothesis-for-django/ http://www.drmaciver.com/2015/06/hypothesis-for-django/ We're all still figuring out the details, but this sort of testing definitely works for testing your applications as well as your algorithms. ETA: Oh, and thanks for the kind words. :-)
- StavrosK 11y agoI didn't, but I will and get back to you. There's certainly a need for randomness in unit tests, since I can't be trusted to write tests for the code I wrote (if I knew everything that would break before writing the tests, I'd fix it in the first place).
- davidrusu 11y agoI've been using hypothesis for testing a decent sized flask project at work and it's been great.
- chriswarbo 11y agoNot sure if it's directly applicable to Hypothesis, but one way to use QuickCheck for interactive code is to define a type representing actions to take, eg. data Action = DoFoo | DoBar | DoSequence [Action] | DoParallel [Action] We can then write an "run" function which executes these action, and use it in our properties.
- DRMacIver 11y agoIt's pretty easy to do this sort of thing in Hypothesis. You can also use [the support for stateful testing directly](http://hypothesis.readthedocs.org/en/latest/stateful.html http://hypothesis.readthedocs.org/en/latest/stateful.html). I find there's still a place for more granular tests that look more like your classic property based tests with a bit more imperative state floating around though.