Immensely grateful for clojure.test.check. It's the first thing I reach for when testing pure functions that have well-defined inputs and outputs. Gives me so much more confidence in the end result than example-based testing.
I love the idea of property testing, but I find that my test code starts to look a lot like my implementation. Have you run into this? If so, how do you avoid it?
I've certainly run into it, yeah. I'm no property-based testing master, and it's still not always easy for me to identify ways to use it. I've found it very useful e.g. when you have a function that transforms data, and both the inputs and the outputs have a schema (clojure.spec or Malli). You can then use test.check to practically ensure that if the input to the transformation function conforms to the input schema, the transformation function yields a result that conforms to the output schema. Another case where I've found it useful is round-tripping. For example, if you have an implementation that e.g. decodes binary data to Clojure data structures and encodes Clojure data structures back to binary data, if you write a schema for the Clojure data structures, you can use test.check to check that encoding any data structure that conforms to the schema and then decoding the result yields the original data structure. https://fsharpforfunandprofit.com/posts/property-based-testing-2/ This is a useful resource. It's for F#, but applicable to any language, I think.
Great advice and resource, I'll have to check it out! Thanks!
I am super grateful for everybody here, specially @didibus @seancorfield @ghaskins @raspasov @bkocin @lukaszkorecki Thanks for helping me learn more about Clojure's ecosystem, within a few hours following your instructions I was able to: • Create a new project • Create an application server (Pedestal) • Add a few simple routes • Add routes that retrieve information from Datomic • Actually have fun with the REPL! Thanks for being kind and eager to help ❤️
Glad to help!