I am using an application using the Stuart Sierra component. As he states in README:
Having a consistent way of setting up and stalling all associated states with the application allows fast development cycles without restarting the JVM. It can also perform unit tests faster and more independent, since the cost of creating and running the system is low enough for each test to create a new instance of the system.
What would be your preferred strategy here? Something similar to JUnit oneTimeSetUp / oneTimeTearDown, or is it really between each test (similar to setUp / tearDown)?
And if between each test there is an easy way to start / stop the system for all tests (before and after) without repeating the code each time?
Edit : sample code to show what I mean
(defn test-component-lifecycle [f]
(println "Setting up test-system")
(let [s (system/new-test-system)]
(f s) ;; I cannot pass an argument here ( https://github.com/clojure/clojure/blob/master/src/clj/clojure/test.clj
(println "Stopping test-system")
(component/stop s)))
(use-fixtures :once test-component-lifecycle)
Note . Here I am talking about unit testing.
source
share