Run tests from Clojure Repl and Leiningen

后端 未结 3 1954
自闭症患者
自闭症患者 2021-01-31 08:14

As a newbie to clojure, I have used leiningen to create a sample project with

lein new app first-project

which gave me this directory



        
3条回答
  •  悲&欢浪女
    2021-01-31 08:57

    Start a REPL with lein repl, then use require

    (require '[clojure.test :refer [run-tests]])
    (require 'your-ns.example-test :reload-all)
    (run-tests 'your-ns.example-test)
    

    I prefer to stay in the user namespace, as opposed to changing it with in-ns as mentioned by another answer. Instead, pass the namespace as an argument to run-tests (as shown above).

    I'd also recommend staying away from (use 'clojure.test); that is why I suggested (require '[clojure.test :refer [run-tests]]) above. For more background, read http://dev.clojure.org/jira/browse/CLJ-879

提交回复
热议问题