clojure - Midje print stacktrace when test fails -
i learning clojure, , trying use tdd *.
i use midje testing library. love far, expected versus actual results display helpfull.
but there way use clojure.tools.trace
or similar print trace of first test fails ?
*: specifically, remember seeing talk robert c. martin transformation priority premise, , i'm implementing factorial function way. there isn't yet code show though.
one possibility writing own emitter might overkill specific goal.
alternatively, can monkey-patch function responsible formatting expected values:
(require '[midje.util.exceptions :as e] '[midje.emission.plugins.util :as u]) (defn- format-captured-throwable [ex] (if (e/captured-throwable? ex) ;; ... adjust needs ... (pr-str 'this-is-your-exception (e/throwable ex)))) (alter-var-root #'u/attractively-stringified-value (fn [f] #(or (format-captured-throwable %) (f %))))
format-captured-throwable
has produce string, though, meaning directly printing stacktrace let end near midje's test report.
user=> (fact (throw (exception. "khaaaaaaaan.")) => :not-khan) fail @ (form-init4689442922606051135.clj:1) expected: :not-khan actual: this-is-your-exception #<exception java.lang.exception: khaaaaaaaan.>
Comments
Post a Comment