简体   繁体   中英

How to print test names in Leiningen?

I would like to print each of my leiningen test methods as they are running. I have a lein tests file that is relatively simple:

(defn myfixture [b] 
  (do 
    (println "start") 
    (b)
    (println "end")
  )
)

(deftest test1 [] .....

I want to see "test1" print out at the repl when I run the tests. Is there a simple way to print the method name (either by calling a method of b in myfixture, or, in the invocation of "lein test")?

You can get the name of a function like this:

(defn function-name [f]
  (:name (meta f))) 

(defn my-func []
   (println "Hello, world!"))

(let [f my-func]
  (function-name f))
;=> my-func

I don't know if the facility that you are looking for exists in the regular clojure.test but midje has some pretty extensive fixture facilities, this link is maybe worth checking out.

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