diff --git a/project.clj b/project.clj index f51ab36..6742bad 100644 --- a/project.clj +++ b/project.clj @@ -5,7 +5,8 @@ :url "http://www.eclipse.org/legal/epl-v10.html"} :dependencies [[org.clojure/clojure "1.10.3" :scope "provided"] [org.clojure/clojurescript "1.10.879" :scope "provided"] - [org.clojure/test.check "1.1.0"] + ;;https://github.com/frenchy64/test.check/pull/1 + [org.clojure/test.check "6e866f163c82ccfe95f0a667d5d8a6c20813c279"] [clj-time "0.15.2"] [com.andrewmcveigh/cljs-time "0.5.2"] [instaparse "1.4.10"]] @@ -13,7 +14,11 @@ :profiles {:ci {:jvm-opts ["-Xmx1g" "-server"]}} :plugins [[lein-cljsbuild "1.1.8"] [lein-doo "0.1.11"] - [com.gfredericks/lein-all-my-files-should-end-with-exactly-one-newline-character "0.1.0"]] + [com.gfredericks/lein-all-my-files-should-end-with-exactly-one-newline-character "0.1.0"] + [reifyhealth/lein-git-down "0.3.5"]] + :middleware [lein-git-down.plugin/inject-properties] + :repositories [["public-github" {:url "git://github.com"}]] + :git-down {org.clojure/test.check {:coordinates frenchy64/test.check}} :cljsbuild {:builds diff --git a/test/com/gfredericks/test/chuck/clojure_test_output_test.cljc b/test/com/gfredericks/test/chuck/clojure_test_output_test.cljc index afffc6c..c3ea550 100644 --- a/test/com/gfredericks/test/chuck/clojure_test_output_test.cljc +++ b/test/com/gfredericks/test/chuck/clojure_test_output_test.cljc @@ -93,6 +93,45 @@ (get-in tc-report path)))) (is (= [{'i 0}] (get-in tc-report [:shrunk :smallest])))))) +;; https://github.com/gfredericks/test.chuck/issues/78 +(deftest an-error-during-gen-test + (try (checking "preamble" {:seed 123456} + [_ (gen/return nil) + :let [_ (throw (ex-info "error during gen" {}))]] + (is true)) + (catch #?(:cljs :default :clj Throwable) e + (is false (.-stack e))))) + +(deftest checking-prints-seed-on-gen-error-test + (let [[test-results all-out] (capture-report-counters-and-out #'an-error-during-gen-test) + ;; skip test preamble + [_ out] (str/split all-out + #".*preamble\n" + 2) + _ (assert out (pr-str {:test-results test-results + :all-out all-out})) + ;; report is printed after `testing` + tc-report (try (edn/read-string + {:readers (assoc default-data-readers + 'error #(-> % + (assoc ::error-tag true)))} + out) + (catch #?(:cljs :default :clj Exception) e + (println (pr-str {:out out + :all-out all-out})) + (throw e))) + error-map-msg-key #?(:clj :cause :cljs :message)] + (testing "clojure.test reporting" + (is (= test-results {:test 1, :pass 0, :fail 1, :error 0}))) + (testing "thrown exception" + (is (false? (:pass? tc-report)) + (pr-str tc-report)) + (is (get-in tc-report [:result ::error-tag])) + (is (get-in tc-report [:result-data :clojure.test.check.properties/error ::error-tag])) + (is (= 123456 (:seed tc-report))) + (is (not (contains? tc-report :shrunk)))))) + (defn test-ns-hook [] (test-vars [#'failure-output-test - #'error-output-test])) + #'error-output-test + #'checking-prints-seed-on-gen-error-test]))