              [xml :refer [emit-str indent parse-str sexp-as-element]]]
             [clojure.java.io :as io :refer [make-parents writer]]
             [clojure.tools.logging :as log]
-            [json-path :refer [at-path]]
-            [dk.ative.docjure.spreadsheet :refer [load-workbook sheet-seq row-seq cell-seq read-cell]]
-            [clojure.data.xml :refer [cdata]])
+            [dk.ative.docjure.spreadsheet
+             :refer
+             [load-workbook read-cell row-seq select-sheet sheet-seq]]
+            [json-path :refer [at-path]])
   (:import [clojure.data.xml CData Element]
            clojure.lang.ExceptionInfo
            java.lang.Integer
-           java.util.concurrent.Executors
+           java.text.SimpleDateFormat
            java.util.Calendar
-           java.text.SimpleDateFormat))
+           java.util.concurrent.Executors))
 
 (def ^:const fields [:suite :test :url :verb :headers :payload :params :exp-status :exp-body
                      :exp-headers :options :extractions])

    (set-agent-send-off-executor! (Executors/newFixedThreadPool pool-size)))
  (try
    (let [opts (apply hash-map (map-indexed #(if (even? %1) (subs %2 1) %2) (rest args)))
          _ (println "running with arguments:" opts)
          tests-file (first args)
          xml-report (or (opts "report")
                         (str "target/" (str/replace tests-file #"\.csv" "-results.xml")))
          results (-> tests-file tests-from (exec-tests opts) summarise-results)]
      ((juxt #(junit-report xml-report tests-file %) print-test-results) results)
      (System/exit (- (results :total 0) (results :success 0))))
    (finally
      (shutdown-agents))))

      (print (if (:success test) "\u001B[32m [v] " "\u001B[31m [x] "))
      (println (:test test) "\t" (or result :success) "\u001B[0m"))))

(defn junit-report [opts src-file {:keys [suites]}]
  (let [dest-file (opts "report.file" (str "target/" (str/replace src-file #"\.[^.]+" "-results.xml")))]
    (make-parents dest-file)
    (with-open [out (writer dest-file)]
      (indent (sexp-as-element
               [:testsuites
                (for [{:keys [name tests total failure error skipped]} suites]
                  [:testsuite {:name name :errors error :tests total :failures failure}
                   (for [test tests]
                     [:testcase {:name (:test test) :classname src-file :time (:time test)}
                      (condp test nil
                        :error :>> #(vector :error {:message %})
                        :failure :>> #(vector :failure {:message %}
                                              [:-cdata (print-http-message test (:resp test))])
                        :skipped [:skipped]
                        nil)])])])
              out))))

(defn -main
  "Executes HTTP requests specified in the argument provided spreadsheet."
