       0
       (throw (IOException. "Java compilation error")))))
 
-(defn- load-class [dir class-name]
+(defn- load-class
   "Load a java class in a specified directory"
+  [dir class-name]
   (let [class-loader
         (URLClassLoader/newInstance
          (into-array [(-> dir .toURI .toURL)]))]
     (Class/forName (name class-name) true class-loader)))
 
-(defn- run-junit-tests [fixture-class]
+(defn- run-junit-tests
+  "Run a JUnit test using the Codewars Formatter for a given fixture-class"
+  [fixture-class]
   (let [runner (JUnitCore.)]
     (.addListener runner (CwRunListener.))
-    (.run runner (into-array [fixture-class]))))
+    (codewars.clojure.test/time
+     (.run runner (into-array [fixture-class])))))
 
-(defn- file-names [files]
+(defn- file-names
+  "Filter a sequence of files writen by write-code! and output their names"
+  [& files]
   (for [{:keys [:file-name]} files
         :when (not (nil? file-name))]
     file-name))

        fixture (write-code! "java" dir fixture)
        setup (when (not (empty? setup)) (write-code! "java" dir setup))
        solution (write-code! "java" dir solution)
        files (file-names [fixture setup solution])]
    (apply compile! files)
    (->> fixture :class-name (load-class dir) run-junit-tests)))

(ns codewars.runner
  (:require [codewars.runner :refer [run]]
            [codewars.clojure.test]
            [clojure.java.io :as io]
            [codewars.util :refer [write-code!]])
  (:import [codewars.java TempDir]
