diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 719a6f7..2f37595 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -92,8 +92,7 @@ (e/wait-visible driver {:id :document-end}) (binding [*driver* driver test-report/*context* (name type)] - (testing (name type) - (f))))))) + (f)))))) (use-fixtures :each diff --git a/test/etaoin/api_with_driver_test.clj b/test/etaoin/api_with_driver_test.clj index 4905017..5cd699d 100644 --- a/test/etaoin/api_with_driver_test.clj +++ b/test/etaoin/api_with_driver_test.clj @@ -120,7 +120,6 @@ (let [test-page (api-test/test-server-url "test.html")] (when (testing-driver? :chrome) (testing "chrome" - (println "testing chrome") ;; with opts (is (= my-agent (e/with-driver :chrome {:user-agent my-agent} driver @@ -186,7 +185,6 @@ (when (testing-driver? :firefox) (testing "firefox" - (println "testing firefox") ;; with opts (is (= my-agent (e/with-driver :firefox {:user-agent my-agent} driver @@ -244,7 +242,6 @@ (when (testing-driver? :edge) (testing "edge" - (println "testing edge") ;; with opts (is (= my-agent (e/with-driver :edge {:user-agent my-agent} driver @@ -302,7 +299,6 @@ (when (testing-driver? :safari) (testing "safari" - (println "testing safari") ;; with opts ;; safari driver does supports neither user agent nor headless ;; not sure what other safari option is reflected in session... port? @@ -344,7 +340,6 @@ (let [test-page (api-test/test-server-url "test.html")] (when (testing-driver? :chrome) (testing "chrome" - (println "testing chrome") (util/with-tmp-file "chromedriver" ".log" path ;; chromedriver logs to stderr (e/with-chrome {:driver-log-level "DEBUG" :log-stderr path} driver @@ -352,7 +347,6 @@ (is (re-find #"\[DEBUG\]:" (slurp path))))))) (when (testing-driver? :edge) (testing "edge" - (println "testing edge") (util/with-tmp-file "edgedriver" ".log" path ;; edgedriver logs to stderr (e/with-edge {:driver-log-level "DEBUG" :log-stderr path} driver @@ -360,7 +354,6 @@ (is (re-find #"\[DEBUG\]:" (slurp path))))))) (when (testing-driver? :firefox) (testing "firefox" - (println "testing firefox") (util/with-tmp-file "firefoxdriver" ".log" path ;; geckodriver logs to stdout (e/with-firefox {:driver-log-level "debug" :log-stdout path} driver diff --git a/test/etaoin/ide_test.clj b/test/etaoin/ide_test.clj index 34518ce..9b446e6 100644 --- a/test/etaoin/ide_test.clj +++ b/test/etaoin/ide_test.clj @@ -2,7 +2,7 @@ (:require [clojure.edn :as edn] [clojure.java.io :as io] - [clojure.test :refer [deftest testing use-fixtures]] + [clojure.test :refer [deftest use-fixtures]] [etaoin.api :as e] [etaoin.ide.flow :as ide] [etaoin.test-report :as test-report])) @@ -37,8 +37,7 @@ *base-url* base-url *test-file-path* test-file-path test-report/*context* (name type)] - (testing (name type) - (f))))))) + (f)))))) (use-fixtures :each diff --git a/test/etaoin/test_report.clj b/test/etaoin/test_report.clj index 183cbf6..0ee21e0 100644 --- a/test/etaoin/test_report.clj +++ b/test/etaoin/test_report.clj @@ -1,8 +1,19 @@ (ns etaoin.test-report - (:require [clojure.test])) + (:require [clojure.test :as t])) (def ^:dynamic *context* nil) +(defmacro testing-with-report + "Replacement for clojure.testing macro that hooks into reporting" + [string & body] + `(let [context# ~string] + (binding [t/*testing-contexts* (conj t/*testing-contexts* context#)] + (t/do-report {:type :begin-testing :testing-contexts t/*testing-contexts*}) + ~@body))) + +;; Replace the clojure.test/testing macro with our custom one +(alter-var-root #'t/testing (constantly #'testing-with-report)) + (def platform (if (System/getProperty "babashka.version") "bb" "jvm")) @@ -11,3 +22,8 @@ (if *context* (println (format "=== %s [%s][%s]" test-name platform *context*)) (println (format "=== %s [%s]" test-name platform))))) + +(defmethod clojure.test/report :begin-testing [{:keys [testing-contexts]}] + (println (format "...%s %s" + (apply str (repeat (count testing-contexts) ".")) + (first testing-contexts))))