Are there any 𝘨𝘰𝘰𝘥 materials/tutorials for Clojure testing? The few I've found from web searches are extremely basic.
@mark.naylor.1701 What have you found so far that is too basic? What books have you read that include testing advice? (so I have a sense of where you're at right now)
@seancorfield Mostly I've seen a couple sites that touch briefly on deftest and the is macro from clojure.test. Maybe some best practices. Should a module have a lot of small deftests or larger ones that touch multiple conditions. I would also like to see more setup examples both the :once and :each variety. I will admit that I grasp some of the abstract ideas of testing and am short on practical experience. That comes from being stuck doing database work for too long and being excluded from an organized development team. I'm trying the get a solid understanding of testing through self study. Going to see what Clojure Programming has to say on the subject.
(Unit) testing doesn't get as much coverage in the Clojure world as perhaps other languages, partly because there's a focus on the REPL and evaluating all your code as you build it, and keeping code simple -- so it's been "tested" and is (mostly) easily determined to be correct by inspection. But I think TDD is still worthwhile with Clojure, where you have a well-specified problem statement and can easily write tests prior to writing the code that satisfies them.
Clojure also has some unique test abilities via Spec and test.check
: Spec lets you describe expected data, expected function arguments, and expected function behavior and all that can be leveraged via tests. See https://corfield.org/blog/2019/09/13/using-spec/ for some insight into how we leverage Spec at work. Automatic generation of test data and generative testing of behavior are pretty game-changing, compared to testing in (most) other languages.
I think Eric Normand's (three) courses on http://PurelyFunctional.tv about "Property-Based Testing with test.check
" are worth a monthly subscription ($49/month for as long as it takes you to get through everything you need -- the "REPL-Driven Development" course is also awesome and everyone should take that course too!).
The Joy of Clojure (2nd Ed) has sections on simulation testing, generative testing, and unit testing, but it predates Clojure Spec. (Clojure Programming also predates Spec)
Programming Clojure (3rd Ed) has a whole chapter on Spec and using it for testing, but doesn't have anything about "plain ol' testing" (without Spec).
Getting Clojure has a whole chapter on testing -- and another whole chapter on Clojure Spec. (I'm going through my bookshelf, seeing what's in each of the Clojure books I own)
Clojure Applied has a short chapter on testing (I expected it to have more on the subject, since it's much more focused on the practical aspects of building production Clojure).
Hope that helps @mark.naylor.1701?