Permalink
Browse files

improve clojure.test integration

  • Loading branch information...
1 parent 228284d commit 15583f7d38436d80db615f509c79442d0f49f46e @stuarthalloway stuarthalloway committed Aug 21, 2012
View
@@ -47,6 +47,11 @@
| :test/pass | | | | | | | info |
| :assert/pass | | | | | | | debug |
| :assert/fail | | | | | | | debug |
+* Keys particular to c.t.
+| name | type |
+|--------------+----------------|
+| c.t/vars | list of symbol |
+| c.t/contexts | list of string |
* Test Events in c.t
| name | becomes | other keys |
|---------------------+-------------------------+--------------------------------------------------|
@@ -29,19 +29,26 @@
(defmethod ctevent->event :fail
[e]
(event/create :type :assert/fail
- ::ctest/testing-contexts (seq ctest/*testing-contexts*)))
+ :level :warn
+ :message (:message e)
+ :test/actual (:actual e)
+ :test/expected (:expected e)
+ :file (:file e)
+ :line (:line e)
+ ::ctest/contexts (seq ctest/*testing-contexts*)
+ ::ctest/vars (reverse (map #(:name (meta %)) ctest/*testing-vars*))))
(defmethod ctevent->event :error
[e]
(event/create :level :error
:type :error
- ::ctest/testing-contexts (seq ctest/*testing-contexts*)
+ ::ctest/contexts (seq ctest/*testing-contexts*)
:message (:message e)
:test/expected (:expected e)
- :test/actual (:actual e)
+ :exception (:actual e)
:file (:file e)
:line (:line e)
- ::ctest/testing-vars (reverse (map #(:name (meta %)) ctest/*testing-vars*))))
+ ::ctest/vars (reverse (map #(:name (meta %)) ctest/*testing-vars*))))
(defmethod ctevent->event :summary
[e]
@@ -81,8 +81,8 @@
#_(defmethod console-reporter :progress [m] (dot-progress m))
(defmethod console-reporter :ignore [_])
(defmethod console-reporter :test/test
- [{:keys [tags msec] :as m}]
- (when (and (tags :end))
+ [{:keys [tags msec count] :as m}]
+ (when (and (tags :end) count)
(println (select-keys m [:msec :test/result :name :count]))))
(defmethod console-reporter :test/group
[{:keys [name tags]}]
@@ -93,6 +93,9 @@
(println (str "\n"
(apply str (repeat 60 "="))
"\nRunning " name " tests\n")))
-(defmethod console-reporter :default [m] (pprint m))
+(defmethod console-reporter :default [m]
+ (when-let [^Throwable t (:exception m)]
+ (send-off serializer (fn [_] (.printStackTrace t))))
+ (pprint m))
@@ -150,6 +150,11 @@
(finally
(event/report :test/group :tags #{:end} :test/threads nthreads :test/count (count fs))))))))
+(defn has-clojure-test-tests?
+ [ns]
+ (or (contains? (ns-interns ns) 'test-ns-hook)
+ (some (comp :test meta) (vals (ns-interns ns)))))
+
(defn run-all-tests
"Run generative tests and clojure.test tests"
[nses threads msec]
@@ -160,7 +165,7 @@
(event/with-handler event-counter
(event/report :test/library :name 'clojure.test)
(binding [ctest/report cta/report-adapter]
- (apply ctest/run-tests nses))
+ (apply ctest/run-tests (filter has-clojure-test-tests? nses)))
(event/report :test/library :name 'clojure.test.generative)
(run-generative-tests nses threads msec)
(io/await)

0 comments on commit 15583f7

Please sign in to comment.