diff --git a/src/leiningen/test.clj b/src/leiningen/test.clj
index a4e5209..275113a 100644
--- a/src/leiningen/test.clj
+++ b/src/leiningen/test.clj
@@ -17,6 +17,11 @@
                       false ~selectors)
           (test-var# var#))))))
 
+(def formats {'tap 'clojure.test.tap/with-tap-output
+              'junit 'clojure.test.junit/with-junit-output})
+
+(def *fmt* 'do)
+
 (defn form-for-testing-namespaces
   "Return a form that when eval'd in the context of the project will test
 each namespace and print an overall summary."
@@ -35,7 +40,8 @@ each namespace and print an overall summary."
                                  first meta :ns ns-name)))
                     (apply report# m# args#)))
               summary# (binding [clojure.test/*test-out* *out*]
-                         (apply ~'clojure.test/run-tests '~namespaces))]
+                         (~*fmt* (apply ~'clojure.test/run-tests
+                                        '~namespaces)))]
           (spit ".lein-failures" (pr-str @failures#))
           (when-not (= "1.5" (System/getProperty "java.specification.version"))
             (shutdown-agents))
@@ -72,9 +78,14 @@ selectors. With no arguments, runs all tests."
     (require '[clojure walk template stacktrace]))
   (let [[nses selectors] (read-args tests project)
         result (doto (File/createTempFile "lein" "result") .deleteOnExit)]
-    (eval-in-project project (form-for-testing-namespaces
-                              nses (.getAbsolutePath result) (vec selectors))
-                     nil nil '(require 'clojure.test))
+    (binding [*fmt* (formats (:test-format project) 'do)]
+      (eval-in-project project (form-for-testing-namespaces
+                                nses (.getAbsolutePath result) (vec selectors))
+                       nil nil `(do (require '~'clojure.test)
+                                    ~(when-let [f (:test-format project)]
+                                       (list 'require
+                                             (->> f formats namespace symbol
+                                                  (list 'quote)))))))
     (if (and (.exists result) (pos? (.length result)))
       (let [summary (read-string (slurp (.getAbsolutePath result)))
             success? (zero? (+ (:error summary) (:fail summary)))]

Generated by Phil Hagelberg using scpaste at Thu May 12 17:25:33 2011. EDT. (raw)