JUnit AfterClass equivalent in Midje Clojure?

97 views Asked by At

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
1

There are 1 answers

4
Conan On

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.