Reputation: 733
I am writing some tests in Clojure and I am wondering whether a def
/defn
inside deftest
is seen from other deftest
in other namespaces. I am also inclined to think that this is bad practice and there is a more idiomatic way to share test functions (to create mocks for instance). Is there?
At the moment, defining:
(deftest tests
(defn- mock-element
[is-valid]
(reify...
Doesn't expose mock-element outside the namespace, or I am doing something wrong. Is there a way to achieve this?
Upvotes: 0
Views: 284
Reputation: 92147
def
is always global: if you want something local, use let
or letfn
:
(deftest tests
(letfn [(mock-element [is-valid]
(reify...)]
...))
Upvotes: 1