This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Add dev dep for clj-time for test runner

  • Loading branch information...
1 parent 08181ac commit 9022a9bbf09c51e34e44590205d7dc672c4c07de @semperos committed Sep 11, 2012
Showing with 55 additions and 0 deletions.
  1. +1 −0 project.clj
  2. +54 −0 test/clj_webdriver/test/runner.clj
View
@@ -16,6 +16,7 @@
[[midje "1.3.1"]
[criterium "0.2.0"]
[codox "0.3.3"]
+ [clj-time "0.4.4"]
[marginalia "0.3.2"]
[ring "1.0.2"]
[enlive "1.0.0"]
@@ -0,0 +1,54 @@
+(ns ^{:doc "Custom Clojure test runner; writes results to log"}
+ clj-webdriver.test.runner
+ (:use clojure.test)
+ (:require [clj-time.local :as t]
+ [clojure.java.io :as io]
+ [clojure.pprint :as pp]
+ clj-webdriver.test.chrome
+ clj-webdriver.test.firefox
+ clj-webdriver.test.remote
+ clj-webdriver.test.remote-existing
+ clj-webdriver.test.taxi
+ clj-webdriver.test.wire))
+
+(def log-file "test.log")
+
+(defn timestamp
+ "Return string timestamp for printing to log file for each test run."
+ []
+ (str (t/local-now)))
+
+(defn format-test-preface
+ [name]
+ (let [test-sep "################################################################################\n"]
+ (str test-sep
+ (timestamp)
+ "TEST RUN FOR "
+ name
+ test-sep)))
+
+(defn run-custom
+ "Given a human-readable name and the namespace to test, format stdout and final results as required."
+ [name ns]
+ (str name " Results: "
+ (with-out-str
+ (pp/pprint (run-tests ns)))))
+
+(defn run-core
+ []
+ (with-open [w (io/writer log-file :append true)]
+ (.write w (format-test-preface "core"))
+ (binding [*out* w
+ *err* w]
+ (.write w (run-custom "Firefox" 'clj-webdriver.test.firefox))
+ (.write w (run-custom "Chrome" 'clj-webdriver.test.chrome)))))
+
+(defn run-core [])
+(defn run-remote [])
+(defn run-taxi [])
+
+(defn run-all
+ []
+ (run-core)
+ (run-remote)
+ (run-taxi))

0 comments on commit 9022a9b

Please sign in to comment.