testing

respatialized 2025-01-04T14:34:11.861079Z

Is there a clojure.test - compatible testing library or testing method that makes it easier to display structured data as I test properties of it? Simplified example: testing properties of a map. Using clojure.test, here's what I am thinking:

(require '[clojure.test :as t])

(defn valid-map? [m] ...) ; complex predicate goes here

(t/deftest example
   (doseq [m [{} {} {} {}]]
    (t/testing m
      (t/is (valid-map? m)))))
By default the test runner will just show the symbol m instead of the runtime value of m, so I have to put the context "back in" by using t/testing. This kinda works to display the data for the map in the test context so I can see why the map currently being tested fails, but it's clearly unwieldy to turn a map into a string like this. How do you keep the "data under test" visible as you run tests and display results?

respatialized 2025-01-04T14:35:56.099599Z

(if it matters, I use Emacs and CIDER's test runner for dev)

respatialized 2025-01-04T14:42:20.672019Z

I think this ClojureVerse thread may cover what I'm looking for: https://clojureverse.org/t/the-best-test-runner-kaocha-or-something-else/9746/8

2025-01-04T14:56:55.403529Z

there's plenty of ways to do this. matcher-combinators can do it

✔️ 1
2025-01-04T15:04:26.239969Z

hmm maybe not if there's a predicate

respatialized 2025-01-04T15:05:14.639689Z

I came back here to report that rewriting my predicate using matcher-combinators solved my exact problem!

🎉 1