dimanche 6 août 2017

How to run tests before start ring server

I'm developing an clojure API and I want to everytime I start my server, run the tests before it.

I've found the function (run-tests) and (run-all-tests) but clojure says that this function does not exist at that namespace. If I put (:use clojure.test) at my ns, the function works, but it runs tests from libs that I'm using and from clojure core.

Here is my handler, where I placed the main method, then I want that "lein run" runs my tests then start the server.

(ns clojure-api.handler
  (:use compojure.core)
  (:require [compojure.route :as route]
            [org.httpkit.server :refer [run-server]]))

(defroutes app-routes 
    ;routes...
)

(def app
  (-> app-routes
      ;Some middleware))

(defn -main  
  [& args]
  (println "Running bank tests")
  (run-all-tests)
  (println "Starting server")
  (run-server app {:port 3000}))

Aucun commentaire:

Enregistrer un commentaire