2013-12-16 22:19:36 +00:00
|
|
|
|
|
|
|
(ns runtests
|
2014-11-29 22:47:57 +00:00
|
|
|
(:require [testreagent]
|
2014-11-29 17:30:24 +00:00
|
|
|
[testcursor]
|
|
|
|
[testinterop]
|
2014-11-29 22:26:42 +00:00
|
|
|
[testratom]
|
|
|
|
[cemerick.cljs.test :as t]
|
|
|
|
[reagent.core :as reagent :refer [atom]]
|
|
|
|
[reagent.interop :refer-macros [.' .!]]
|
2014-11-29 22:47:57 +00:00
|
|
|
[reagent.debug :refer-macros [dbg println]]))
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2014-11-29 22:47:57 +00:00
|
|
|
(enable-console-print!)
|
2013-12-16 22:19:36 +00:00
|
|
|
|
|
|
|
(def test-results (atom nil))
|
|
|
|
|
2014-11-29 17:30:24 +00:00
|
|
|
(def test-box {:position 'absolute
|
|
|
|
:margin-left -35
|
|
|
|
:color :#aaa})
|
|
|
|
|
2013-12-16 22:19:36 +00:00
|
|
|
(defn test-output []
|
|
|
|
(let [res @test-results]
|
2014-11-29 17:30:24 +00:00
|
|
|
[:div {:style test-box}
|
2013-12-16 22:19:36 +00:00
|
|
|
(if-not res
|
|
|
|
[:div "waiting for tests to run"]
|
|
|
|
[:div
|
|
|
|
[:p (str "Ran " (:test res) " tests containing "
|
|
|
|
(+ (:pass res) (:fail res) (:error res))
|
|
|
|
" assertions.")]
|
2014-03-18 12:09:55 +00:00
|
|
|
[:p (:fail res) " failures, " (:error res) " errors."]])]))
|
2013-12-16 22:19:36 +00:00
|
|
|
|
2014-01-06 18:16:53 +00:00
|
|
|
(defn test-output-mini []
|
|
|
|
(let [res @test-results]
|
|
|
|
(if res
|
|
|
|
(if (zero? (+ (:fail res) (:error res)))
|
2014-11-29 17:30:24 +00:00
|
|
|
[:div {:style test-box}
|
|
|
|
"All tests ok"]
|
2014-01-06 18:16:53 +00:00
|
|
|
[test-output])
|
2014-11-29 17:30:24 +00:00
|
|
|
[:div {:style test-box} "testing"])))
|
2014-01-06 18:16:53 +00:00
|
|
|
|
2014-01-25 16:02:58 +00:00
|
|
|
(defn ^:export run-all-tests []
|
|
|
|
(println "-----------------------------------------")
|
|
|
|
(try
|
|
|
|
(reset! test-results (t/run-all-tests))
|
|
|
|
(catch js/Object e
|
|
|
|
(do
|
|
|
|
(println "Testrun failed\n" e "\n" (.-stack e))
|
|
|
|
(reset! test-results {:error e}))))
|
|
|
|
(println "-----------------------------------------"))
|
|
|
|
|
2014-11-29 22:26:42 +00:00
|
|
|
(defn ^:export run-tests []
|
2014-11-29 17:30:24 +00:00
|
|
|
(if reagent/is-client
|
|
|
|
(do
|
|
|
|
(reset! test-results nil)
|
|
|
|
(js/setTimeout run-all-tests 100))
|
|
|
|
(run-all-tests)))
|