简体   繁体   中英

JUnit AfterClass equivalent in Midje Clojure?

I could not find any Midje function that runs after all facts.

Here is the code:

(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")))

Actual Output is:

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

Expected Output is:

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

You can wrap all your facts in a with-state-changes to achieve this, but beware that Clojure has a limit to the maximum size of a top-level form. To avoid that problem you can use namespace-state-changes to perform setup and teardown at the beginning and end of an entire file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM