Permalink
Browse files

Add tests that run on SauceLabs

The integration is by no means complete, but with the correct configuration in place (not in VCS) tests in clj-webdriver.test.saucelabs will run on SauceLabs.
  • Loading branch information...
1 parent 334f3eb commit de7dd65e09ffc84811d42ef33476bdc59b9cf154 @semperos committed Dec 18, 2012
Showing with 55 additions and 2 deletions.
  1. +13 −2 script/test
  2. +42 −0 test/clj_webdriver/test/saucelabs.clj
View
@@ -10,7 +10,7 @@ EXPECTED_ARGS=1
E_BADARGS=65
DO_showUsage() {
- echo "Usage: $(basename $0) {all|core|firefox|remote|taxi|window}"
+ echo "Usage: $(basename $0) {all|core|firefox|remote|saucelabs|taxi|window}"
exit $E_BADARGS
}
@@ -44,6 +44,15 @@ DO_testCore() {
lein test clj-webdriver.test.chrome
}
+DO_testSauceLabs() {
+ echo ""
+ echo "############################"
+ echo "## Testing with SauceLabs ##"
+ echo "############################"
+ echo ""
+ TEST_BASE_URL=http://vast-brushlands-4998.herokuapp.com/ lein test clj-webdriver.test.saucelabs
+}
+
DO_testRemote() {
echo ""
echo "####################"
@@ -105,6 +114,9 @@ case "$1" in
remote)
DO_testRemote
;;
+ saucelabs)
+ DO_testSauceLabs
+ ;;
taxi)
DO_testTaxi
;;
@@ -114,4 +126,3 @@ case "$1" in
*)
DO_showUsage
esac
-
@@ -0,0 +1,42 @@
+(ns ^{:doc "Tests running on SauceLabs using 'Open Sauce' subscription"}
+ clj-webdriver.test.saucelabs
+ (:require [clojure.test :refer [deftest use-fixtures]]
+ [clj-webdriver.core :refer [quit to]]
+ [clj-webdriver.properties :refer [*properties*]]
+ [clj-webdriver.test.config :refer [base-url]]
+ [clj-webdriver.test.common :refer [run-common-tests]]
+ [clj-webdriver.remote.server :refer [new-remote-session stop]])
+ (:import [java.util.logging Level]))
+
+(def server (atom nil))
+(def driver (atom nil))
+
+(defn start-session-fixture
+ [f]
+ (let [{:keys [host port]} (:saucelabs *properties*)
+ [this-server this-driver] (new-remote-session {:host host
+ :port port
+ :existing true}
+ {:browser :firefox})]
+ (-> this-driver :webdriver (.setLogLevel Level/OFF))
+ (reset! server this-server)
+ (reset! driver this-driver))
+ (f))
+
+(defn reset-browser-fixture
+ [f]
+ (to @driver (base-url))
+ (f))
+
+(defn quit-fixture
+ [f]
+ (f)
+ (quit @driver)
+ (stop @server))
+
+(use-fixtures :once start-session-fixture quit-fixture)
+(use-fixtures :each reset-browser-fixture)
+
+;; RUN TESTS HERE
+(deftest test-common-features-via-remote-server
+ (run-common-tests @driver))

0 comments on commit de7dd65

Please sign in to comment.