jakemcc / test-refresh

Refreshes and reruns clojure.tests in your project.
393 stars 28 forks source link

Supporting clojure.test/with-test #21

Closed giorgio-v closed 10 years ago

giorgio-v commented 10 years ago

Would it be possible to extend lein-test-refresh to support the clojure.test/with-test macro?

Basically, I’d like to auto run tests defined in this way:

(test/with-test
  (defn hello [name]
    (str "Hello, " name))
  (is (= (hello "Brian") "Hello, Brian"))
  (is (= (hello nil) "Hello, ")))

Right now, these are not loaded by lein-test-refresh because they are attached as meta data to the functions.

jakemcc commented 10 years ago

I haven't had a chance to try it but I think the actual problem is that lein-test-refresh only reruns tests found under the :test-paths entry in the project.clj file. It used to attempt to run tests in the entire project but the noise of running tests in :source-paths was annoying.

Can you try adding your source directory to the :test-paths entry? If that works is that acceptable?

giorgio-v commented 10 years ago

I’ve tried adding the source directory, but it’s the same.

jakemcc commented 10 years ago

Had some time to take a look at this and was able to get lein test-refresh to run tests attached to functions using clojure.test/with-test.

Below is my project.clj. This seemed to be enough to get it working. Was able to make changes to my code and see attached tests fail and succeed on file changes.

(defproject test-in-code "0.1.0-SNAPSHOT"
  :test-paths ["src" "test"]
  :dependencies [[org.clojure/clojure "1.6.0"]]
  :profiles {:dev {:plugins [[com.jakemccrary/lein-test-refresh "0.5.1"]]}})
giorgio-v commented 10 years ago

Ah you’re right. I was mislead by having tests in both paths.