diff --git a/test/etaoin/api_test.clj b/test/etaoin/api_test.clj index 64809732..2152954e 100644 --- a/test/etaoin/api_test.clj +++ b/test/etaoin/api_test.clj @@ -10,7 +10,8 @@ [etaoin.api :as e] [etaoin.impl.util :as util] [etaoin.test-report :as test-report] - [slingshot.slingshot :refer [try+]])) + [slingshot.slingshot :refer [try+]]) + (:import [java.net ServerSocket])) (defn numeric? [val] (or (instance? Double val) @@ -50,7 +51,11 @@ (def ^:dynamic *driver*) -(def test-server-port 8888) +(defn- find-available-port [] + (with-open [sock (ServerSocket. 0)] + (.getLocalPort sock))) + +(def test-server-port (find-available-port)) (defn- test-server-url [path] (format "http://localhost:%d/%s" test-server-port path)) @@ -77,7 +82,8 @@ (f)) (defn test-server [f] - (let [proc (p/process "bb test-server")] + (let [proc (p/process {:out :inherit :err :inherit} + "bb test-server --port" test-server-port)] (f) (p/destroy proc) @proc))