1 つの可能性は、独自のエミッターを作成することですが、それは特定の目的にとってはやり過ぎかもしれません。
または、期待値のフォーマットを担当する関数にモンキー パッチを適用することもできます。
(require '[midje.util.exceptions :as e]
'[midje.emission.plugins.util :as u])
(defn- format-captured-throwable
[ex]
(if (e/captured-throwable? ex)
;; ... adjust this to your 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
ただし、文字列を生成する必要があります。つまり、スタック トレースを直接出力すると、midje のテスト レポートにはほど遠い結果になります。
user=> (fact (throw (Exception. "khaaaaaaaan.")) => :not-khan)
FAIL at (form-init4689442922606051135.clj:1)
Expected: :not-khan
Actual: this-is-your-exception #<Exception java.lang.Exception: khaaaaaaaan.>