简体   繁体   English

如何在莱宁根打印测试名称?

[英]How to print test names in Leiningen?

I would like to print each of my leiningen test methods as they are running.我想在运行时打印我的每个 leiningen 测试方法。 I have a lein tests file that is relatively simple:我有一个相对简单的 lein 测试文件:

(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.我想在运行测试时在 repl 中看到“test1”打印出来。 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")?是否有一种简单的方法可以打印方法名称(通过调用 myfixture 中的 b 方法,或者调用“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.我不知道您正在寻找的设施是否存在于常规的 clojure.test 中,但是midje有一些非常广泛的固定设施, 这个链接可能值得一试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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