Back

use-fixtures (clj)

(source)

multimethod

Wrap test runs in a fixture function to perform setup and teardown. Using a fixture-type of :each wraps every test individually, while :once wraps the whole run in a single function.

Examples

metabase/metabase
(ns metabase.server.middleware.log-test
  (:require
   [clojure.test :refer :all]
   [metabase.server.middleware.log :as mw.log]
   [metabase.test.fixtures :as fixtures]))

(use-fixtures :once (fixtures/initialize :db))
metabase/metabase
(ns ^:mb/once metabase.task.follow-up-emails-test
  (:require
   [clojure.test :refer :all]
   [metabase.email-test :refer [inbox with-fake-inbox]]
   [metabase.task.follow-up-emails :as follow-up-emails]
   [metabase.test.fixtures :as fixtures]
   [metabase.test.util :as tu]))

(use-fixtures :once (fixtures/initialize :test-users))
metabase/metabase
(ns metabase.plugins.driver-deprecation-test
  (:require
   [clojure.test :refer :all]
   [metabase.models.setting :as setting]
   [metabase.test :as mt]
   [metabase.test.fixtures :as fixtures]))

(use-fixtures :once (fixtures/initialize :db :plugins :test-drivers))
metabase/metabase
(ns dev.model-tracking-test
  (:require
   [clojure.test :refer :all]
   [dev.model-tracking :as model-tracking]
   [metabase.models :refer [Collection]]
   [metabase.test :as mt]
   [toucan2.core :as t2]))

(use-fixtures :each (fn [thunk]
                      (model-tracking/untrack-all!)
                      (thunk)))
metabase/metabase
(ns metabase.db.force-migration-test
  (:require
   [clojure.test :refer :all]
   [metabase.db.connection :as mdb.connection]
   [metabase.db.custom-migrations :as custom-migrations]
   [metabase.db.liquibase :as liquibase]
   [metabase.db.setup :as db.setup]
   [metabase.driver :as driver]
   [metabase.test :as mt]
   [metabase.test.fixtures :as fixtures]
   [toucan2.core :as t2])
  (:import
   (liquibase.lockservice LockServiceFactory)))

(use-fixtures :once (fixtures/initialize :db))