This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-12
Channels
- # announcements (15)
- # babashka (8)
- # babashka-sci-dev (8)
- # beginners (19)
- # biff (18)
- # cider (7)
- # clj-kondo (1)
- # clojure (6)
- # clojure-europe (24)
- # clojure-norway (10)
- # clojure-spec (1)
- # clojurescript (11)
- # conjure (1)
- # core-async (1)
- # cursive (3)
- # devops (1)
- # emacs (1)
- # fulcro (1)
- # helix (4)
- # keechma (1)
- # off-topic (19)
- # pathom (4)
- # reagent (2)
- # reitit (1)
- # shadow-cljs (8)
- # spacemacs (1)
- # vim (7)
Looking for resources to learn to describe "properties" for property-based testing. Can't find anything much deeper than a sales-pitch, with the only meaningful example of a property being that a list reversed twice should be the same as it started.
https://youtu.be/H18vxq-VsCk is very good
https://youtu.be/zi0rHwfiX1Q is likely also good, but I don't recall if I've seen it
https://fsharpforfunandprofit.com/posts/property-based-testing-2/ may also be a good read, the dropbox testing in the first video would fall under what this series calls model based testing
A property is the set of all possible allowed values you want your function to be able to handle. So if you take a list of numbers you might have two properties, the first is how many numbers, the second might be what range. In the end, it's a tool for testing your expectations. That's how i think of it, i rarely find a use for property based testing simply because most things i do are very coupled and not useful reusable.
https://github.com/sicmutils/sicmutils/search?q=checking&type= I use a ton in this library if you want some examples
https://github.com/sicmutils/sicmutils/blob/main/test/sicmutils/laws.cljc these are some bread and butter mathematical ones I use for all sorts of types
Rewatching this, I realize it is actually a pretty good stepping stone. I must have not been ready to internalize it when I watched it previously. It is the http://fsharpforfunandprofit.com article that @U0NCTKEV8 linked above fleshed out into a 50 minute presentation. https://www.youtube.com/watch?v=IYzDFHx6QPY
Also realizing that even though choosing appropriate properties is probably the more difficult and more important skill in the long-run, the bigger hurdle to getting started is learning to build generators for interestingly shaped data. If anyone is thinking of putting together learning materials on the topic. It would be really helpful to have good lessons available on building small-but-nontrivial generators.
Dan Luu has some interesting materials on testing. Here https://danluu.com/testing/ and elsewhere.
I’ve found Eric Normand’s talk on testing stateful systems very helpful https://www.youtube.com/watch?v=r5i_OiZw6Sw&t=1349s
@U9V9M9MFZ I've watched that one, and it seems like I will want to come back to it. But there is a humongous chasm between never having written property tests and worrying about how to apply it to stateful things.
@U90R0EPHA I found this particularly helpful to understand generators better: https://www.youtube.com/watch?v=F4VZPxLZUdA
Agreed @U05476190. That vid is how I was actually able get started. But it's a bit of a whirlwind. Still took a lot more digging through the test.check docs and trial and error and dead ends to find my way through my own first example of generating 2 maps from the same list of keys and a list of the keys from one of those maps. And was afterward left still feeling like I don't know what I'm doing.
Also realizing that even though choosing appropriate properties is probably the more difficult and more important skill in the long-run, the bigger hurdle to getting started is learning to build generators for interestingly shaped data. If anyone is thinking of putting together learning materials on the topic. It would be really helpful to have good lessons available on building small-but-nontrivial generators.