1

I'm trying to use midje to test a future, but I can't seem to get it to work.

The code looks like

(defn foo []
  (let [f (future (bar))]
    (baz @f))

With a test like

(fact 
  (foo) => ..a..
  (provided
    (bar) => ..b..
    (baz ..b..) => ..a..))

This fails, saying that bar never gets called. Any way around this?

aciniglio
  • 1,777
  • 1
  • 16
  • 18

1 Answers1

2

This code shows that midje test wait until the dereferencing future var, so i think midje with futures is not your problem but other in the sequence functions you have

(defn foo []
  (let [state (future (Thread/sleep 1000) (println "done") "done")]
      @state
    )

  )
(fact "description of the fact"
      "done" => (foo))
==>true

Good luck!

tangrammer
  • 3,041
  • 17
  • 24