Skip to content

Instantly share code, notes, and snippets.

@camsaul
Created August 18, 2025 20:21
Show Gist options
  • Save camsaul/2210ba7807d82cadbff625a70e4e3ee2 to your computer and use it in GitHub Desktop.
Save camsaul/2210ba7807d82cadbff625a70e4e3ee2 to your computer and use it in GitHub Desktop.
Split tests
(defn split-tests [[_deftest test-name & args]]
(into []
(comp (mapcat (fn split* [expr]
(case (first expr)
is (let [[_is assert-expr message] expr]
[(if message
(list 'testing message
(list 'is assert-expr))
(list 'is assert-expr))])
testing (let [[_testing message & exprs] expr]
(for [expr (mapcat split* exprs)]
(list 'testing message expr)))
#_else
[expr])))
(map-indexed (fn [i expr]
(list (symbol "deftest ^:parallel")
(symbol (str test-name "-" (inc i)))
expr))))
args))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment