testing

James Carr 2021-12-01T17:25:51.010100Z

Asked this question in #clojure before noticing this channel, is there a resource for best practices testing clojure?

👍 1
mauricio.szabo 2021-12-06T16:29:39.011800Z

I think the same rules for testing on other languages apply to Clojure: 1. Avoid testing "internal state" and "implementation details", test more the behavior 2. Try to make the test convey information. Instead of (is (= {...big-map...} (my-fun))), try to use (is (= valid-user (my-fun))) 3. Try to use a better matching library, like expectations for example. My choice is matcher-combinators There are some that I also add for Clojure: 1. Avoid fixtures. It's hard to get them right and you lose some of the REPL capabilities like running a fragment of your test. I prefer to write macros that will do the setup and teardown 2. If you're using ClojureScript, be aware of async testing - it's REALLY hard. I would recommend a library that handles that for you 3. Property testing is amazing, but it's a different kind of test. It does not replace integration/unit-ish tests

💯 2
💡 1