简体   繁体   中英

Clojure: Timbre and clojure.test namespaces

Trying to get Timbre to load in my test project along with clojure.test . My first attempt is

(ns foo.core-test
  (:require [clojure.test :refer :all]
            [taoensso.timbre :as timbre]
            [foo.core :refer :all]))

which compiles until I follow the next step in the Timbre documentation, adding

(timbre/refer-timbre) ; Provides useful Timbre aliases in this ns

I now get the following compile error

IllegalStateException report already refers to #'clojure.test/report in namespace foo.core-test
clojure.lang.Namespace.warnOrFailOnReplace (Namespace.java:88)

ok, groovy, I'll try

(ns foo.core-test ; ------vvvvvvvvvvvvvvvv-----
  (:require [clojure.test :exclude [report]]
            [taoensso.timbre :as timbre]
            [foo.core :refer :all]))

mmmm, nope. I notice that clojure has a report , too. How about

(ns foo.core-test
  (:refer-clojure :exclude [report])
  (:require [clojure.test :refer :all]
            [taoensso.timbre :as timbre]
            [foo.core :refer :all]))

mmmmm, nope.

I hacked around for a while till I got tired of combinatorial trial-and-error. I haven't found a way to make them coexist. Any clues, please & thanks?

There's no report in clojure.core . In your second ns form you seem to be missing :refer :all for clojure.test . Try the following form:

(ns foo.core-test
  (:require [clojure.test :refer :all :exclude [report]]
            [taoensso.timbre :as timbre]
            [foo.core :refer :all]))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM