Test for tests with the same `deftest` name that don't get executed

Hi Everybody,

After some issues in my program I realized that my tests don’t work since by mistake I created two sets of tests with the same name.

(deftest same-name
...

(deftest same-name
...

Could you please tell me is it possible to create some parent test that tests that I’m not an idiot that re-defines test and therefore some tests don’t get executed?

Thank you.

Kind reqards,

Ozzy

I am an idiot all the time and am often saved by clj-kondo.

4 Likes

clj-kondo is the best way since it understands code. grep is the fastest way but will fail if you format your code in a different way.

(ns myapp.testit
  (:require [clojure.test :refer :all]
            [clojure.java.shell :as sh]))

(deftest no-repeating
  (is (= (sh/sh "bash" "-c" "out=$(grep -Ir '(deftest ' test/ | sort) ; diff <(printf '%s\n' \"${out}\") <(printf '%s\n' \"${out}\" | uniq)")   {:exit 0 :out "" :err ""})))

Tested on Linux, should work on macOS and BSD.