duct

iarenaza 2020-06-03T16:53:46.116300Z

Ok, so there are two possible approaches. If you want to use the same handler in different deftest functions, you want to keep the handler in a top-level var. E.g., you could create an atom to hold all the handlers (and other system elements) that you want to use in several deftests. You add/remove them in your fixture, and access (use) them in our tests through the atom. This is a skeleton of this idea (might have slight errors, I didn't test it in the REPL):

(def system (atom {}))

(defn init-handler []
  (ig/init-key :delme.handler/example {}))

(defn halt-handler [system]
  (ig/halt-key! system))

(defn init-halt-handler [f]
  (reset! system (init-handler))
  (f)
  (halt-handler @system))

(use-fixtures :once init-halt-handler)

(deftest smoke-test
  (let [handler (:delme.handler/example @system)
   ....))

(deftest another-smoke-test
  (let [handler (:delme.handler/example @system)
   ....))

(deftest even-another-smoke-test
  (let [handler (:delme.handler/example @system)
   ....))
The other approach is to have multiple testing block in a single deftest. In that case, you have a let block in the deftest defining your handler (and every other system element you want to use in your tests) and use them from your testing blocks. E.g.
clj

(deftest smoke-test
  (let [handler (ig/init-key :delme.handler/example {})]
    (testing "example page exists"
      (let [response (handler (mock/request :get "/example"))]
        (is (= 200 (:status response)) "response ok")))
    (testing "example2 page exists"
      (let [response (handler (mock/request :get "/example2"))]
        (is (= 200 (:status response)) "response ok")))

    ;; More `testing` blocks here...

    (testing "example3 page does not exist"
      (let [response (handler (mock/request :get "/example3"))]
        (is (= 404 (:status response)) "page not found")))))