Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; test that the test framework behaves as expected because the doco is abstract
- (ns com.quzanti
- (:use clojure.test)
- (:import java.util.TreeSet)
- )
- (def whats-run (new TreeSet))
- (def onceres nil)
- (def eachres nil)
- (def oncevar (new StringBuffer))
- (def eachvar (new StringBuffer))
- (defn once-test-fixture
- [zefn]
- (binding [onceres (do (. oncevar append "o")
- (. oncevar toString))]
- (println "once test called")
- (zefn)
- )
- )
- (use-fixtures :once once-test-fixture)
- (defn each-test-fixture
- [zefn]
- (binding [eachres (do (. eachvar append "e")
- (. eachvar toString))]
- (println "each test called")
- (zefn)
- )
- )
- (use-fixtures :each each-test-fixture)
- (with-test
- (defn once-firstly
- []
- (. whats-run add "a")
- (println "Doing once firstly")
- onceres
- )
- (is (= (once-firstly) "o"))
- )
- (with-test
- (defn once-secondly
- []
- (. whats-run add "b")
- (println "Doing once secondly")
- onceres
- )
- (is (= (once-secondly) "o"))
- )
- (with-test
- (defn each-firstly
- []
- (. whats-run add "c")
- (println "Doing each firstly")
- eachres
- )
- (is (= (each-firstly) (apply str (repeat (. whats-run size) "e"))))
- (is (= (each-firstly) (apply str (repeat (. whats-run size) "e"))))
- )
- (with-test
- (defn each-secondly
- []
- (. whats-run add "d")
- (println "Doing each secondly")
- eachres
- )
- (is (= (each-secondly) (apply str (repeat (. whats-run size) "e"))))
- (is (= (each-secondly) (apply str (repeat (. whats-run size) "e"))))
- )
Add Comment
Please, Sign In to add comment