在Midje Clojure中,JUnit AfterClass等效?

时间:2016-11-12 18:58:53

标签: unit-testing clojure lisp clojurescript midje

我找不到任何在所有事实之后运行的 Midje 函数。

以下是代码:

(background
  (before :contents (println "Before All Facts"))
  (after :contents (println "After All Facts"))
  (before :facts (println "Before Each Fact"))
  (after :facts (println "After Each Fact")))

实际输出为:

Before All Facts
After All Facts
Before Each Fact
After Each Fact

预期输出为:

Before All Facts
Before Each Fact
After Each Fact
After All Facts

1 个答案:

答案 0 :(得分:1)

您可以将所有事实包装在with-state-changes中以实现此目的,但要注意Clojure对顶级表单的最大大小有限制。为避免此问题,您可以使用namespace-state-changes在整个文件的开头和结尾执行设置和拆卸。