mockfn icon indicating copy to clipboard operation
mockfn copied to clipboard

Can't nest `verifying` and `providing` in a `let` within `testing`

Open dchelimsky opened this issue 5 years ago • 0 comments

The implementation of testing looks for verifying and providing in child forms, but does not look deeper, resulting in the following inconsistency:

(mockfn.clj-test/deftest a-test
  (let [one 1]
    (mockfn.clj-test/testing "addition"
      (clojure.test/is (= 3 (add one 2)))
      (mockfn.clj-test/verifying (add 1 2) 3 (mockfn.matchers/at-least 1)))))

;; passes

(mockfn.clj-test/deftest another-test
  (mockfn.clj-test/testing "addition"
    (let [one 1]
      (clojure.test/is (= 3 (add one 2)))
      (mockfn.clj-test/verifying (add 1 2) 3 (mockfn.matchers/at-least 1)))))
      
;; java.lang.IllegalStateException: Attempting to call unbound fn: #'mockfn.clj-test/verifying

Recommendation: either support verifying and providing within a let within testing or document it as a quirk.

dchelimsky avatar Mar 18 '20 18:03 dchelimsky